RequestParam value in spring MVC to be case insensitive

前端 未结 6 2105
离开以前
离开以前 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:06

    Another approach would be to have two parameters "orgId" and "orgid" and have the optional.

    public String welcome(@RequestParam(value="orgID", required = false) String org_ID, @RequestParam(value="orgid", required=false, String orgid, ModelMap model) {
    final String orgId = orgid == null ? org_ID : orgid;
    ...
    }
    

    But if you have control over the parameters I would strongly prefer to just have one consistent way, say org-id and follow it both in the client and the server side.

提交回复
热议问题