The request was rejected because the URL contained a potentially malicious String ";"
时间: 2024-01-05 22:18:44 浏览: 29
这个错误信息是由Spring Security防火墙引起的,它会检查URL中是否包含潜在的恶意字符,例如分号“;”等。如果检测到这些字符,防火墙将拒绝请求并返回该错误信息。
为了解决这个问题,你可以尝试以下几种方法:
1. 如果你确定URL中包含的分号是合法的,请将其编码为“%3B”。
2. 如果你使用的是Spring Security 4.2或更高版本,可以通过配置来禁用防火墙检查。在你的Spring Security配置文件中添加以下代码:
```java
http
.headers()
.defaultsDisabled()
.contentTypeOptions()
.and()
.csrf()
.disable()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.exceptionHandling()
.accessDeniedHandler(new OAuth2AccessDeniedHandler());
```
3. 如果你使用的是Spring Security 3.x版本,可以通过配置来禁用防火墙检查。在你的Spring Security配置文件中添加以下代码:
```java
<http>
<http-basic />
<intercept-url pattern="/**" access="ROLE_USER" />
<csrf disabled="true"/>
<headers>
<frame-options policy="SAMEORIGIN"/>
</headers>
<custom-filter ref="requestRejectedExceptionTranslationFilter" position="PRE_AUTH_FILTER"/>
</http>
<beans:bean id="requestRejectedExceptionTranslationFilter" class="org.springframework.security.web.access.ExceptionTranslationFilter">
<beans:constructor-arg>
<beans:bean class="org.springframework.security.web.access.ExceptionTranslationFilter">
<beans:property name="authenticationEntryPoint" ref="http403ForbiddenEntryPoint"/>
</beans:bean>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="http403ForbiddenEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>
```