征服Spring编码世界Java&Spring基础技术

Spring Security(2) 自定义登录页面

2017-05-26  本文已影响108人  憨厚的老菜鸟

开发环境

自定义登录页面

spring-security.xml

    <http pattern="/static/**" security="none"  />
    <http security="none" pattern="/loginPage" />

    <http auto-config="true" >
        <form-login login-page="/loginPage" default-target-url="/hello" always-use-default-target="true" authentication-failure-url='/loginPage?error' username-parameter="username" password-parameter="password"/>
        <intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>
        <csrf disabled="true"/>
    </http>

<http pattern="/static/**" security="none" /> 配置不想被拦截的URL

form-login 配置自定义的登录页面

<csrf disabled="true"/> 关闭csrf,打开的话,需要在页面中加入csrf token

上一篇下一篇

猜你喜欢

热点阅读