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. 春季安全
- 3. 春季安全
- 4. Vaadin春季安全
- 5. 春季安全mysuccessHandler
- 6. BCryptPasswordEncoder春季安全
- 7. 與春季安全
- 8. AccessDeniedException;春季安全
- 9. 春季安全badcredentials
- 10. 春季3.5安全
- 11. 從春季安全
- 12. 春季安全春季啓動4.x
- 13. 安全註釋在春季安全
- 14. 如何保存春季安全RedirectUrl
- 15. 安全REST與春季安全
- 16. Grails的春季安全 - 安全= 「無」
- 17. 內容安全策略春季安全
- 18. 春季安全ACL號
- 19. 春季安全會議
- 20. 刪除春季安全@PreAuthorize
- 21. 春季安全csrf爲空
- 22. 春季安全角色
- 23. CSRF令牌春季安全
- 24. 春季安全登錄
- 25. 春季安全總是302
- 26. 春季安全和Tomcat
- 27. 檢票1.6.6春季安全
- 28. 春季安全3 + JCIFS ntlm
- 29. 春季安全無密碼
- 30. 春季安全元註釋