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. 春季安全註銷