[英]Spring Security Login issue
我是Spring Security的新手,已经在Spring MVC应用程序中配置了Spring Security。
提交登录页面后,出现以下错误
The requested resource (/j_spring_security_check) is not available.
我无法理解这种行为。
请帮忙。
弹簧security.xml文件
<security:http auto-config="true" use-expressions="true" access-denied-page="/appln/denied">
<security:intercept-url pattern="/appln/login" access="permitAll" />
<security:intercept-url pattern="/appln/index" access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/appln/run" access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/appln/common" access="hasRole('ROLE_USER')" />
<security:form-login login-page="/appln/login"
authentication-failure-url="/appln/login?error=true"
default-target-url="/appln/run"
authentication-success-handler-ref="AuthHandlr" />
<security:logout invalidate-session="true"
logout-success-url="/appln/login"
delete-cookies="JSESSIONID" />
</security:http>
在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>
<servlet>
<servlet-name>servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
解决了问题。
在我的loginpage.jsp中,action属性定义为
action=../../j_spring_security_check
我在玩上面的游戏,并将其更改为
action = /j_spring_security_check
而且没有任何问题。
尽管问题已解决,但任何人都不能请您详细说明更改路径的原因。
表单动作可以是“ j_spring_security_check”或“ / j_spring_security_check”。
这是Spring-Security中的默认值,无法更改。
同样,表单字段必须为“ j_username”和“ j_password”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.