当前位置: 代码迷 >> J2EE >> Spring Security 无法拦截,该怎么处理
  详细解决方案

Spring Security 无法拦截,该怎么处理

热度:468   发布时间:2016-04-22 02:38:22.0
Spring Security 无法拦截
我在配置Spring Security的时候,遇到了一个问题。我想用/admin/admin!login.do这个Struts2的请求作为登录页面,登录成功后跳转到/admin/admin!main.do,我用Spring Security作为身份验证,我的web.xml文件内容如下:
XML code
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5"     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_5.xsd">        <!-- 防止Hibernate延迟加载session关闭 begin -->    <filter>        <filter-name>OpenSessionInViewFilter</filter-name>        <filter-class>            org.springframework.orm.hibernate3.support.OpenSessionInViewFilter        </filter-class>    </filter>    <!-- 防止Hibernate延迟加载session关闭 end -->            <!-- Spring Begin -->    <context-param>        <param-name>contextConfigLocation</param-name>        <param-value>classpath:spring.xml</param-value>    </context-param>    <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    </listener>    <!-- Spring End -->        <!-- Spring Security过滤器 begin -->    <filter>        <filter-name>springSecurityFilterChain</filter-name>           <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>    </filter>    <!-- Spring Security过滤器 end -->        <!-- Struts Begin -->    <filter>        <filter-name>struts2</filter-name>        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>    </filter>    <!-- Struts End -->            <!-- 页面缓存过滤器(for oscache) begin -->    <filter>        <filter-name>cacheFilter</filter-name>        <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class>        <init-param>            <param-name>time</param-name>            <param-value>3600</param-value>        </init-param>        <init-param>            <param-name>scope</param-name>            <param-value>application</param-value>        </init-param>    </filter>    <!-- 页面缓存过滤器(for oscache) end -->        <!-- oscache缓存(标签) begin -->    <taglib>         <taglib-uri>oscache</taglib-uri>         <taglib-location>/WEB-INF/classes/oscache.tld</taglib-location>     </taglib>     <!-- oscache缓存(标签) end -->        <!-- 防止Hibernate延迟加载session关闭(URL) begin -->    <filter-mapping>        <filter-name>OpenSessionInViewFilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>    <!-- 防止Hibernate延迟加载session关闭(URL) end -->            <!-- Spring Security(URL) begin -->    <filter-mapping>        <filter-name>springSecurityFilterChain</filter-name>        <url-pattern>/admin/*</url-pattern>    </filter-mapping>    <!-- Spring Security(URL) end -->        <!-- Struts2过滤器(URL) begin -->    <filter-mapping>        <filter-name>struts2</filter-name>        <url-pattern>*.do</url-pattern>    </filter-mapping>    <!-- Struts2过滤器(URL) end -->        <!-- JSPSupportServlet配置 begin -->    <servlet>        <servlet-name>JSPSupportServlet</servlet-name>        <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>        <load-on-startup>1</load-on-startup>    </servlet>    <!-- JSPSupportServlet配置 end -->        <welcome-file-list>      <welcome-file>index.jsp</welcome-file>    </welcome-file-list></web-app>
  相关解决方案