Java Spring Security每个URL都是一个空白页

Java Spring Security每个URL都是一个空白页,java,xml,spring,spring-mvc,spring-security,Java,Xml,Spring,Spring Mvc,Spring Security,我需要你的帮助。 我正在尝试编写一个具有Spring安全性的web应用程序。我正在使用Tomcat 7.0.56来运行它。 但当我向web.xml添加以下行时: <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:sch

我需要你的帮助。 我正在尝试编写一个具有Spring安全性的web应用程序。我正在使用Tomcat 7.0.56来运行它。 但当我向web.xml添加以下行时:

<web-app id="WebApp_ID" version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Spring MVC Application</display-name>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <!-- Spring MVC -->
    <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>



    <!-- Loads Spring Security config file -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring-security.xml
        </param-value>
    </context-param>

    <!-- Spring Security -->
    <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>

</web-app>

SpringMVC应用程序
org.springframework.web.context.ContextLoaderListener
mvc调度器
org.springframework.web.servlet.DispatcherServlet
1.
mvc调度器
/
上下文配置位置
/WEB-INF/spring-security.xml
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
此应用程序中的每个URL都显示为空白页

以下是spring-security.xml:

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

       <http auto-config="true">
              <intercept-url pattern="/admin**" access="ROLE_USER" />
       </http>

       <authentication-manager>
              <authentication-provider>
                     <user-service>
                            <user name="user" password="123456" authorities="ROLE_USER" />
                     </user-service>
              </authentication-provider>
       </authentication-manager>

</beans:beans>

和mvc-dispatcher-servlet.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <mvc:annotation-driven/>
       <context:component-scan base-package="controller" />

       <bean
               class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <property name="prefix">
                     <value>/WEB-INF/pages/</value>
              </property>
              <property name="suffix">
                     <value>.jsp</value>
              </property>
       </bean>

</beans>

/WEB-INF/pages/
.jsp
我编写的每个具有Spring安全性的web应用程序都会出现这种情况,即使我只是按照教程中的说明操作


我不明白怎么了。如果您还需要什么,请告诉我。

设置spring security的日志级别以进行调试,并查看日志。也许这会帮助你谢谢你!问题出在spring-security.xml中的模式声明中