Controller获取url中多个同名参数

href=“${
     pageContext.request.contextPath }/orders?oiid=21&oiid=22&oiid=23

用这种方式传多个相同参数,后台接收到的是一组数组oiid{16,17,18},也可以用字符串接收

数组形式接收参数:

@RequestMapping(value="orders",method=RequestMethod.GET)
Public String orders ( Integer[]  oiid ) {
     
For ( Integer id : oiid ) {
     
System.out.println(id);
}
}

字符串形式接收参数:

@RequestMapping (value="orders",method = RequestMethod.GET)
Public String  orders ( String  oiid ) {
     
String[]  Arr = oiid.split(",");
For ( String id1 : Arr ) {
     
System.out.println(Integer.parseInt(id));
}
}

你可能感兴趣的:(java)