0

Here is my code-

@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);
    }

inside my jsp file where from we are caaling this controller method.-

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

how to obtain the values of it in controller?

Prabhakaran Ramaswamy
  • 25,706
  • 10
  • 57
  • 64
identify
  • 75
  • 1
  • 8
  • 1
    Try this http://stackoverflow.com/questions/17560258/pass-array-data-from-javascript-in-browser-to-spring-mvc-controller-using-ajax – Pokuri Sep 26 '13 at 10:12

1 Answers1

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){
           }
       }
}

Now sortIds array have these values [1,2, 3, 4 , 5]

Prabhakaran Ramaswamy
  • 25,706
  • 10
  • 57
  • 64