【发布时间】:2013-12-22 16:34:41
【问题描述】:
我遇到了弹簧安全问题并显示错误消息
这是我的 root-context.xml 中的内容
`<context:property-placeholder location="classpath:config.properties" />
<!-- Register the Customer.properties -->
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="mymessages" />
</bean>
<security:http auto-config='true'>
<security:intercept-URL pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-URL pattern="/**" access="ROLE_USER" />
<security:form-login login-page='/login' default-target-url="/"
authentication-failure-URL="/loginfailed"/>
<security:logout logout-success-url="/" logout-URL="/j_spring_security_logout" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="billy" password="123456" authorities="ROLE_USER" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>`
在我的 web.xml 中是
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<URL-pattern>/*</URL-pattern>
</filter-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
我的 .jsp 是
<body>
<%@ include file="include/login1.jsp"%>
<c:if test="${not empty error}">
<div class="errorblock">Your login attempt was not successful, try again.<br/> Caused :
</div>
</c:if>
</body>
</html>
当我第一次使用错误的用户凭据登录时,它只是重新加载登录页面。然后,如果我使用正确的登录凭据登录,它将加载登录并显示文本“您的登录尝试不成功,请重试。原因:”但在原因之后没有提示错误凭据的弹簧消息: 非常感谢您对此事的任何帮助
【问题讨论】:
-
对不起我的上一条评论,我贴错了。我的意思是为什么你的 web.xml 定义了两次
springSecurityFilterChain? -
嘿,谢谢您的回复。过滤器重复只是复制过去的错误。在我的实际代码中不是这样的(第一次发布:-/)
标签: java spring jsp spring-mvc