Spring MVC 中的 RequestParam 值不区分大小写 [英] RequestParam value in spring MVC to be case insensitive

查看:112
本文介绍了Spring MVC 中的 RequestParam 值不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在使用查询字符串将数据从 JSP 发送到控制器.

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-insensitive.

我用于欢迎页面的方法是

The method which i use for welcome page is

public String welcome(@RequestParam("orgID") String orgID, ModelMap model)

请求参数orgID"应该不区分大小写.如何做到这一点?.

The request parameter "orgID" should be case insensitive. How to do this ?.

我应该能够将查询字符串指定为orgid"或orgId".该参数应完全不区分大小写.寻找你的帮助朋友.

I should be able to give the query-string as "orgid" or "orgId". The parameter should be completely case-insensitive. Looking for your help friends.

提前致谢:-)

推荐答案

有一个简单的解决方法,可以直接操作HttpServletRequest,使用getParameter()方法查看所有版本的参数.

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
}

这篇关于Spring MVC 中的 RequestParam 值不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆