RequestParam value in spring MVC to be case insensitive

前端 未结 6 2140
离开以前
离开以前 2021-01-17 20:40

Am sending data from JSP to controller using query string.

My controller is annotation driven.

The value of the the request parameter should be case-insensit

6条回答
  •  难免孤独
    2021-01-17 21:21

    There is a simple workaround.You can operate directly on the HttpServletRequest and use method getParameter() and check all versions of parameter.

    public String welcome(HttpServletRequest request, ModelMap model){
       String orgID = extractOrgId(request);
       //rest of your code
    }
    
    private String extractOrgId(HttpServletRequest request){
       if(request.getParameter("orgId") != null){
           return request.getParameter("orgId");
       }
       // and so on
    }
    

提交回复
热议问题