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)

Mark Ma
  • 1,342
  • 3
  • 19
  • 35

1 Answers1

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.

Community
  • 1
  • 1
gknicker
  • 5,509
  • 2
  • 25
  • 41
  • Thanks! you even helped me solved the next question.. (I'm using jQuery to build the query URL) – Mark Ma Jan 28 '15 at 09:08
  • Related: this is also the reason for the need to [alter the code of dropzone.js to make it work with Struts2](http://stackoverflow.com/a/26080212/1654265), for example. – Andrea Ligios Jan 28 '15 at 09:22