yusq456
2019-02-18 14:03
采纳率: 14.3%
浏览 1.3k
已采纳

Spring security 设置多登陆页面,xml配置不成功

Spring security 设置多登陆页面,security 3.1
xml配置信息如下:

<http auto-config='true' use-expressions="true">
        <logout />
        <session-management></session-management>
        <form-login login-page="/index" authentication-failure-url="/index?login_error=t"   always-use-default-target="true" default-target-url="/"></form-login>
        <custom-filter ref="myFilter" before="FILTER_SECURITY_INTERCEPTOR" />
    </http>

尝试过配置多个,但没有成功,只一个登陆页面出来
xml 配置信息如下:

<http auto-config='true' pattern="/admin" use-expressions="true"> 
        <logout />
        <session-management></session-management>
        <remember-me />
        <form-login login-page="/index" authentication-failure-url="/index?login_error=t"
            always-use-default-target="true" default-target-url="/"></form-login>
            <custom-filter ref="myFilter" before="FILTER_SECURITY_INTERCEPTOR" />
</http>
<http auto-config='true' pattern="/user" use-expressions="true">
        <logout />
        <session-management></session-management>
        <remember-me />
        <form-login login-page="/login" authentication-failure-url="/login?login_error=t"
            always-use-default-target="true" default-target-url="/"></form-login>
        <custom-filter ref="myFilter" before="FILTER_SECURITY_INTERCEPTOR" />
</http>

页面报错如下:
HTTP Status 405 - Request method 'GET' not supported
图片说明

单登陆页面配置如下:

<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.1.xsd">

    <!-- exclude static resources -->
    <http pattern="/resources/**" security="none" />
    <http pattern="/app/**" security="none"></http>
    <http pattern="/**/*.jpg" security="none"></http>
    <http pattern="/**/*.ico" security="none"></http>
    <http pattern="/**/*.xlsx" security="none"></http>
    <http pattern="/**/*.xls" security="none"></http>
    <!-- exclude login page -->
    <http pattern="/login" security="none" />
    <http pattern="/index" security="none" />
    <http auto-config='true' pattern="/admin" use-expressions="true">
        <logout />
        <session-management></session-management>
        <!-- 实现免登陆验证 -->  
        <remember-me />
        <intercept-url pattern="/login" access="ROLE_USER" />
        <intercept-url pattern="/index" access="ROLE_SYSTEM" />
        <form-login login-page="/index" authentication-failure-url="/index?login_error=t"
            always-use-default-target="true" default-target-url="/"></form-login>
        <custom-filter ref="myFilter" before="FILTER_SECURITY_INTERCEPTOR" />
    </http>
    <authentication-manager alias="myAuthenticationManager">
        <authentication-provider user-service-ref="myUserDetailServiceImpl">
            <password-encoder hash="md5">
                <salt-source system-wide="bgrimm" />
            </password-encoder>
        </authentication-provider>
    </authentication-manager>
</beans:beans>

请大佬帮忙下!!
QQ 756233642

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题