问候所有,我正在使用spring security 3.0.2,urlRewrite 3.1.0,我有一个Spring安全问题,我有一个规则,即应用程序中的所有页面都需要身份验证,除了某些页面,所以我的security.xml是:
<http use-expressions="true" >
<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/error" filter="none" />
<intercept-url pattern="/**" access="isAuthenticated()" />
.
.
.</http>
Run Code Online (Sandbox Code Playgroud)
在web.xml中我定义了错误页面
<error-page>
<error-code>404</error-code>
<location>/p/error</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)
问题是,如果我不是登录用户,并输入app/notFoundUrl等应用程序中不存在的某个url,则spring安全性将此页面与需要身份验证的模式/**匹配,因此用户是未按预期重定向到错误页面,但重定向到登录页面,然后重定向到错误页面
我希望如果用户输入了一个坏网址,如果他已经登录,他会直接重定向到错误页面.
我认为这个问题与web.xml有关,这就是它:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Beans in these files will makeup the configuration of the root web application context -->
<!-- Bootstraps the root web application context before servlet initialization-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Deploys the 'projects' dispatcher servlet whose configuration resides in /WEB-INF/servlet-config.xml-->
<servlet> …Run Code Online (Sandbox Code Playgroud)