0

The user wants to add a tag and its related files. He will access the Struts2 action by following query URL:

Test/addTag?tag=java&files[]=1.java&files[]=2.java&files[]=3.java

In the past I was using HttpServletRequest.getParameterValues() method to parse the files[] parameter and it worked perfectly.

But after migrating the architecture to Struts2 (I was using JSP+Servlet before), it doesn't work anymore. I tried following ways to define the files[] field in Struts2 Acton, but neither works (it always return null when calling the getter method)

private String files;
private String[] files;
private List<String> files;

(By the way the tag parameter could be parsed correctly)

1

1 Answer 1

0

Struts2 doesn't like the files[]=1.java&files[]=2.java query string format.

Use the traditional files=1.java&files=2.java instead. See also this answer.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! you even helped me solved the next question.. (I'm using jQuery to build the query URL)
Related: this is also the reason for the need to alter the code of dropzone.js to make it work with Struts2, for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.