无法加载登录页面-Spring Security

时间:2018-11-24 10:21:20

标签: spring spring-mvc spring-security

我已经设置了spring mvc项目,现在想在其中实现Spring-Security。
我之前有Spring 3.2.8版本的jars,所以我包括了同一版本3.2.8的Spring-security jars。

security-context.xml

 <http authentication-manager-ref="custom" auto-config="true"
        use-expressions="true" disable-url-rewriting="true">

        <!-- <intercept-url pattern="pages/login/login.jsp" access="permitAll"/> -->
        <intercept-url pattern="/index.jsp" access="permitAll"/>
        <!-- <intercept-url pattern="/pages/login/login.jsp" access="permitAll"/> -->
        <intercept-url pattern="/login*" access="permitAll" />

        <intercept-url pattern="/css/**" access="permitAll" />
        <intercept-url pattern="/image/**" access="permitAll" />
        <intercept-url pattern="/images/**" access="permitAll" />
        <intercept-url pattern="/include/**" access="permitAll" />
        <intercept-url pattern="/javascript/**" access="permitAll" />


        <intercept-url pattern="/userAuthentication.htm/**" access="isAuthenticated()"/>
        <intercept-url pattern="/**" access= "isAuthenticated()"/>

        <form-login login-page="/login"
            default-target-url="/userAuthentication.htm?method=login"
            always-use-default-target="false" password-parameter="j_password"
            username-parameter="j_username"
            authentication-failure-url="/pages/errorPage/unauthorizedAccess.jsp?login_error=1" />
        </http>

        <authentication-manager id="custom"
        alias="authenticationManager">
        <authentication-provider ref="customAuthenticationProvider" />
    </authentication-manager>


        </beans:beans>

web.xml

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/config/spring/spring-config.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


<filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter>
        <filter-name>sanitizerFilter</filter-name>
        <filter-class>com.mobicule.util.SanitizerFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<% response.sendRedirect(request.getContextPath()+ "/login"); %>

我的一个Controller中也有/ login请求映射,它返回新的ModelAndView(“ login / login”)
我仍然发现找不到网页-花费了很长时间才能回复

我对缺少的配置感到困惑??,
无法找到目录下的我的login.jsp页面
Web-Content / pages / login / login.jsp

我也正在使用Tomcat 6,因为这是我的项目的要求。

0 个答案:

没有答案