在spring mvc

时间:2017-06-08 05:24:56

标签: java spring-mvc spring-security

我有春季mvc项目,我试图添加弹簧安全性但是在添加弹簧安全过滤器和列表器项目停止工作后如果我删除了listner然后当我输入url i必须得到保护它要求我添加列表。

这里是我的web.xml

    <web-app version="2.5"
             xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


    <!--
        <listener>
            <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
        </listener>

        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/</url-pattern>
        </filter-mapping>-->
        <!--<listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>-->
        <servlet>
            <servlet-name>spring</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
            <servlet-name>spring</servlet-name>
            <url-pattern>*.html</url-pattern>
        </servlet-mapping>

        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/*.xml
            </param-value>
        </context-param>
        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/welcome.html</url-pattern>
        </filter-mapping>

    </web-app>

弹簧security.xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <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.xsd">

        <http auto-config="true">
            <intercept-url pattern="/**" access="ROLE_USER"/>
            <form-login login-page="/login" login-processing-url="j_spring_security_check" authentication-failure-url="/login"/>
            <logout logout-success-url="/login" />
        </http>

        <authentication-manager alias="authenticationManager">
            <authentication-provider ref="AuthenticationProvider"/>
        </authentication-manager>

        <beans:bean id="AuthenticationProvider" class="com.javatpoint"></beans:bean>

    </beans:beans>

错误我正在

enter image description here

你能不能建议我在这个配置中做错了什么

0 个答案:

没有答案