1
Q
如何在春季安全
A
回答
1
您不需要自定义控制器。
你只需要一个JSP(x)中提出的两个值
j_username
j_password
,需要更改配置为使用表单
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http auto-config="true" use-expressions="true">
<logout logout-url="/static/j_spring_security_logout"/>
<form-login login-processing-url="/static/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t"/>
<intercept-url pattern="/js/**" access="permitAll" />
<intercept-url pattern="/css/**" access="permitAll" />
<intercept-url pattern="/images/**" access="permitAll" />
<intercept-url pattern="/static/**" access="permitAll" />
<intercept-url pattern="/login**" access="permitAll" />
<intercept-url pattern="/**" access="isAuthenticated()" />
</http>
...
重要提示:您无需对01进行身份验证以及login-processing-url
!
- 登录页==当用户需要输入用户名和密码
- 登录处理的URL显示的页面==用户的用户名和密码提交到
login.jspx:
<spring:url value="/static/j_spring_security_check" var="form_url" />
<form name="f" action="${fn:escapeXml(form_url)}" method="POST">
<input type='text' name='j_username' />
<input type='password' name='j_password' " />
<c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" />
</form>
3
添加定义,就像下面你Spring上下文。
<security:http>
<security:form-login login-page='/login' authentication-failure-url="/login?authfailed=true"/>
<security:logout />
</security:http>
您还必须使用<security:intercept-url>
定义URL模式。
相关问题
- 1. 春季安全
- 2. AccessDeniedException;春季安全
- 3. 春季安全badcredentials
- 4. Vaadin春季安全
- 5. BCryptPasswordEncoder春季安全
- 6. 春季3.5安全
- 7. 从春季安全
- 8. 春季安全春季启动4.x
- 9. 安全注释在春季安全
- 10. 春季安全hasIpAddress问题
- 11. 春季安全spnego ldap jwt
- 12. 春季安全实例
- 13. 春季安全LDAP连接
- 14. CSRF令牌春季安全
- 15. 春季安全大气
- 16. 春季安全无密码
- 17. 春季云流安全
- 18. 春季安全3 + JCIFS ntlm
- 19. 春季安全CSRF保护
- 20. 春季安全角色
- 21. 春季安全:Autowired userDetailsService
- 22. 什么是春季安全
- 23. AOP VS春季安全
- 24. 春季启动LDAP安全
- 25. 春季安全:autowire ProviderManager
- 26. 春季安全元注释
- 27. 春季安全启动404
- 28. 春季安全userCache无效
- 29. 春季安全加密MD5
- 30. 春季安全注销