Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Security中带有查询参数的URL的regexMatcher_Spring_Spring Mvc_Spring Security - Fatal编程技术网

Spring Security中带有查询参数的URL的regexMatcher

Spring Security中带有查询参数的URL的regexMatcher,spring,spring-mvc,spring-security,Spring,Spring Mvc,Spring Security,我应该如何在Spring Security的regexMatcher中使用这样的参数?我有许多URL以/sUrl开头,并且有不同的参数。这个代码不起作用 .regexMatchers(\\/sUrl\\?params=\\{url:\\'reports\\\/Manager\,subSystem:\'ABS\\\}).access(“hasRole('ROLE\u ABS')”) 控制器: @RequestMapping(value=“sUrl”,method=RequestMethod.GE

我应该如何在Spring Security的
regexMatcher
中使用这样的参数?我有许多URL以
/sUrl
开头,并且有不同的参数。这个代码不起作用

.regexMatchers(\\/sUrl\\?params=\\{url:\\'reports\\\/Manager\,subSystem:\'ABS\\\}).access(“hasRole('ROLE\u ABS')”)
控制器:

@RequestMapping(value=“sUrl”,method=RequestMethod.GET)
公共重定向视图sUrl(@RequestParam(name=“params”)字符串参数){
RedirectView RedirectView=新建RedirectView();
.
.
.
返回重定向视图;
}
单击此链接时在浏览器检查器的网络分区中看到的URL:

sUrl?params={url:%22报表/管理器%22,子系统:%22ABS%22}


必须将正则表达式与查询参数一起使用,请参见:

使用正则表达式确定提供的URL是否为提供的
HttpServletRequest
的URL。也可以配置为匹配特定的HTTP方法。对请求的
servletPath
+
pathInfo
+
queryString
执行匹配,默认情况下区分大小写。不区分大小写的匹配可以通过使用构造函数来使用,该构造函数接受
不区分大小写的
参数

以及:

返回路径后请求URL中包含的查询字符串。如果URL没有查询字符串,则此方法返回
null
。与CGI变量QUERY_字符串的值相同

返回:

包含查询字符串的
字符串
,如果URL不包含查询字符串,则为
null
。容器不会对该值进行解码

您的modfified代码:

.regexMatchers("\\/sUrl\\?params=\\{url:%22reports\\/Manager\%22,subSystem:%22ABS%22\\}").access("hasRole('ROLE_ABS')")