SpringMVC RequestMapping for GET parameters

前端 未结 6 2006
执念已碎
执念已碎 2020-12-07 12:21

How to make the RequestMapping to handle GET parameters in the url? For example i have this url

http://localhost:8080/userGrid?_search=false&nd=135197257         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-07 12:54

    This will get ALL parameters from the request. For Debugging purposes only:

    @RequestMapping (value = "/promote", method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView renderPromotePage (HttpServletRequest request) {
        Map parameters = request.getParameterMap();
    
        for(String key : parameters.keySet()) {
            System.out.println(key);
            String[] vals = parameters.get(key);
            for(String val : vals)
                System.out.println(" -> " + val);
        }
    
        ModelAndView mv = new ModelAndView();
        mv.setViewName("test");
        return mv;
    }
    

提交回复
热议问题