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

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

问题描述

是从JSP发送数据使用查询字符串到控制器。

Am sending data from JSP to controller using query string.

我的控制器驱动注释

的请求参数的值应该是不区分大小写。

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.

在此先感谢: - )

推荐答案

有一个简单的workaround.You可以直接在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
}

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

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