404从Tomcat 6迁移到Tomcat 7后/spring\u security\u登录spring security 3.2时出错
现在已经三天了,我正在努力使我的申请再次生效。 要点:我有一个使用SpringSecurity3.2的应用程序,在Tomcat6上运行良好 我想在Tomcat7上迁移我的所有应用程序,所以我正在尝试这样做 但是:每次我访问我的应用程序的根目录时,我都会看到一个404错误页面,URL中写着/spring\u security\u登录名。 对于编写的/spring\u security\u登录,它似乎部分合法,因为spring被设置为自己创建登录表单。但是为什么会出现404错误呢? 在Tomcat6上,使用相同的web.xml和applicationContext安全性,该站点运行良好 最后但并非最不重要的一点是,我的登录是通过SpringSecurityLDAP提供程序进行的,因此它增加了一个更高级别的复杂性 这是我的web.xml:404从Tomcat 6迁移到Tomcat 7后/spring\u security\u登录spring security 3.2时出错,spring,tomcat,spring-security,ldap,tomcat7,Spring,Tomcat,Spring Security,Ldap,Tomcat7,现在已经三天了,我正在努力使我的申请再次生效。 要点:我有一个使用SpringSecurity3.2的应用程序,在Tomcat6上运行良好 我想在Tomcat7上迁移我的所有应用程序,所以我正在尝试这样做 但是:每次我访问我的应用程序的根目录时,我都会看到一个404错误页面,URL中写着/spring\u security\u登录名。 对于编写的/spring\u security\u登录,它似乎部分合法,因为spring被设置为自己创建登录表单。但是为什么会出现404错误呢? 在Tomcat6
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>MYAPP</display-name>
<!-- où se trouve la conf spring: -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-security.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<!-- Reads request input using UTF-8 encoding -->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- configuration spring -->
<servlet>
<servlet-name>myapp-webapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myapp-webapp</servlet-name>
<url-pattern>*.do</url-pattern>
<url-pattern>/remoting/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
<url-pattern>*.js</url-pattern>
<url-pattern>*.css</url-pattern>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/myapp_database</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
MYAPP
上下文配置位置
/WEB-INF/applicationContext-security.xml
org.springframework.web.context.ContextLoaderListener
org.springframework.security.web.session.HttpSessionEventPublisher
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
字符编码滤波器
org.springframework.web.filter.CharacterEncodingFilter
编码
UTF-8
强制编码
真的
字符编码滤波器
/*
springSecurityFilterChain
/*
myapp网络应用程序
org.springframework.web.servlet.DispatcherServlet
3.
myapp网络应用程序
*.做
/远程处理/*
违约
*.png
*.js
*.css
*.gif
数据库连接
jdbc/myapp_数据库
javax.sql.DataSource
容器
和我的applicationContext-security.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<s:global-method-security secured-annotations="disabled">
</s:global-method-security>
<s:http pattern="/styles/**" security="none"/>
<s:http pattern="/js/**" security="none"/>
<s:http pattern="/img/**" security="none"/>
<s:http pattern="/html/**" security="none"/>
<s:http pattern="/remoting/**" security="none"/>
<!-- config ldap activee use-expressions="true" -->
<s:http auto-config="true" create-session="always" access-decision-manager-ref="accessDecisionManager">
<s:intercept-url pattern="/cancelPreviousAction.do" access="P_MYAPP_RW" />
<s:intercept-url pattern="/**" access="P_MYAPP_RO" />
<s:session-management>
<s:concurrency-control max-sessions="1" />
</s:session-management>
<s:form-login />
<s:logout/>
</s:http>
<s:authentication-manager>
<s:authentication-provider ref="ldapProvider"></s:authentication-provider>
</s:authentication-manager>
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="..." />
<property name="userDn" value="..." />
<property name="password" value="..." />
</bean>
<bean id="ldapProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource" />
<property name="userSearch">
<bean id="userSearch"
class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg index="0" value="..." />
<constructor-arg index="1" value="..." />
<constructor-arg index="2" ref="..." />
</bean>
</property>
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
<constructor-arg ref="contextSource" />
<constructor-arg value="..." />
<property name="rolePrefix" value="" />
<property name="searchSubtree" value="true" />
<property name="convertToUpperCase" value="false" />
</bean>
</constructor-arg>
</bean>
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<property name="allowIfAllAbstainDecisions" value="false" />
<property name="decisionVoters">
<bean class="org.springframework.security.access.vote.RoleVoter">
<property name="rolePrefix" value=""/>
</bean>
</property>
</bean>
</beans>
有人有线索吗
有一次我认为可能是我的Tomcat配置导致的,但现在当我调用我的应用程序的根url时,/spring\u security\u登录会附加在url中,所以我认为spring Seucriyt内部的重定向工作得很好
注意:当我从web.xml文件中删除spring安全过滤器时,应用程序运行良好(登录/安全部分除外)
提前谢谢 事实上,问题是在Tomcat6下,我覆盖了默认servlet的定义 在搜索了很久很久之后,我试着对默认的servlet定义进行注释。。。一切顺利 因此,在web.xml中,注释以下行,使其具有相同的内容:
<!--
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
<url-pattern>*.js</url-pattern>
<url-pattern>*.css</url-pattern>
<url-pattern>*.gif</url-pattern>
</servlet-mapping> -->
它修复了所有问题。在从tomcat 6迁移到7的过程中,上下文根是否发生了变化?我不这么认为,但上下文根到底是什么意思?应用程序在tomcat中运行的上下文。也许你改了?从“myapp”到根上下文还是什么?因为我的假设是,对登录url的请求与tomcat认为应用程序运行的位置不匹配。但这只是一个想法:)好吧,为什么不呢。可能是这样。但是为什么当我移除Spring安全过滤器时,应用程序运行良好?这就是我认为web.xml和/或applicationContext security.xml…jep有问题的地方。web.xml中的过滤器映射是否就是您在此处发布的?web.xml是否已完成,或者是否删除了某些部分?