Recent development encountered a page pass array to the action background list type, the Received list object is not imagined according to the array element position corresponding to the acceptance, such as the array of 0 bits inserted into the list object 0 position,
Instead, the entire contents of the array are inserted into the first position of the list collection. After repeated experiments, did not find a good solution, can only be the rough way to record the implementation, in order to make a point of hope that we can give a better way to achieve.
This is the JSP page code: Asynchronously submitting an array to the action:
insert title here Test
test
test
test
test
Background Java code: An array of accepted page passes that is inserted into the first position of the list collection after a test array.
@Controller @Scope ("prototype") public class Loginaction extends Actionsupport { private List Ajaxfield = new ArrayList (); public void Testarray () { string str = (string)
Ajaxfield.get (0);
System.out.println (str);
list List = new arraylist ();
string[] STRs = Str.split (","); for (String string:strs) {
System.out.println (string);
List.add (string); } for (int i = 0; i < Ajaxfield.size (); i++) { System.out.println(Ajaxfield.get (i)); }
HttpServletResponse response = Servletactioncontext.getresponse (); try {
PrintWriter write = Response.getwriter ();
Response.setcontenttype ("text/html"); Write.print ("Hello"); Write.flush (); write.close (); } catch (IOException e) {&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&Nbsp; E.printstacktrace (); } }
Although the process of implementing array delivery is somewhat flawed, it is still true for asynchronous Ajax delivery, but it is also useful to pass the variable only if the array is not passed.