ajax pass array and background receive

 Ajax passes {"items":arr}, where arr=[];

In the background String[] items=req.getParameterValues("items"); find that it cannot be received, print the parameter name

Enumeration<String> names = req.getParameterNames();
  while (names.hasMoreElements()) {
  String string = (String) names.nextElement();
  System.out.println(string);
}

The print is "items[]", so it is changed to String[] items=req.getParameterValues("items[]"); for correct reception

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324740012&siteId=291194637