far*_*raa 4 spring spring-mvc spring-security
regexMatcher我应该如何在Spring Security 中使用这样的参数?我有许多以 开头/sUrl且具有不同参数的 URL。这段代码不起作用!
.regexMatchers("\\/sUrl\\?params=\\{url:\"reports\\/Manager\",subSystem:\"ABS\"\\}").access("hasRole('ROLE_ABS')")
Run Code Online (Sandbox Code Playgroud)
控制器:
@RequestMapping(value = "sUrl", method = RequestMethod.GET)
public RedirectView sUrl(@RequestParam(name = "params") String params) {
RedirectView redirectView = new RedirectView();
.
.
.
return redirectView;
}
Run Code Online (Sandbox Code Playgroud)
当我点击此链接时,在浏览器检查器的网络分区中看到的 URL:
sUrl?params={url:%22reports/Manager%22,子系统:%22ABS%22}
您必须将正则表达式与URL 编码的查询参数结合使用,请参阅RegexRequestMatcher:
使用正则表达式来决定是否提供了所提供的 URL
HttpServletRequest。还可以配置为匹配特定的 HTTP 方法。匹配根据请求的servletPath++执行pathInfo,queryString并且默认区分大小写。可以通过使用接受caseInsensitive参数的构造函数来使用不区分大小写的匹配。
返回请求 URL 中路径后面包含的查询字符串。
null如果 URL 没有查询字符串,则此方法返回。与 CGI 变量 QUERY_STRING 的值相同。返回:
a
String包含查询字符串,或者null如果 URL 不包含查询字符串。该值不被容器解码。
您修改后的代码:
.regexMatchers("\\/sUrl\\?params=\\{url:%22reports\\/Manager\%22,subSystem:%22ABS%22\\}").access("hasRole('ROLE_ABS')")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9186 次 |
| 最近记录: |