0

这是我的代码-

@controller
public ModelAndView ServiceContract(HttpServletRequest httpServletRequest,
            HttpServletResponse httpServletResponse) {      
        int sortId = Integer.parseInt(httpServletRequest.getParameter("sortId"));
                ModelMap map = new ModelMap();
        map.addAttribute("jsonString",jsonStringX); 
        return new ModelAndView(jsonView,map);
    }

在我的jsp文件中,我们从哪里开始这个控制器方法。-

var sortId= [1,2, 3, 4 , 5];

如何在控制器中获取它的值?

4

1 回答 1

0
String sortId = httpServletRequest.getParameter("sortId");
int sortIds[] = null;
if(sortId !=null){
       String array[] = sortId.split(",");
       sortIds = new int[array.length];
       for(int i=0;i<array.length;i++){
           try{
            sortIds[i] = Integer.parseInt(array[i]); 
           }catch(Exception e){
           }
       }
}

现在 sortIds 数组具有这些值 [1,2, 3, 4 , 5]

于 2013-09-26T10:15:53.950 回答