請問下這種方式怎么整合spring security
網上整合都是這種需要applicationContext.xml一起使用的:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
? ? ? ? ?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
? ? ? ? ?xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
? ? ? ? ?version="3.1">
? ? <!--spring 和security ?配置文件-->
? ? <context-param>
? ? ? ? <param-name>contextConfigLocation</param-name>
? ? ? ? <param-value>classpath:applicationContext.xml,classpath: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>
? <listener>
? ? ? ? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
? ? </listener>
? <!--spring mvc 配置文件-->
? ? <servlet>
? ? ? ? <servlet-name>SpringMVC</servlet-name>
? ? ? ? <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
? ? ? ? <init-param>
? ? ? ? ? ? <param-name>contextConfigLocation</param-name>
? ? ? ? ? ? <param-value>classpath:spring-servlet.xml</param-value>
? ? ? ? </init-param>
? ? ? ? <load-on-startup>1</load-on-startup>
? ? </servlet>
? ? <servlet-mapping>
? ? ? ? <servlet-name>SpringMVC</servlet-name>
? ? ? ? <url-pattern>*.do</url-pattern>
? ? </servlet-mapping>
</web-app>
這個架構沒有applicationContext.xml,如果不用這個文件的話,我直接配置:
<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>
配置了這個listener之后又說缺少applicationContext.xml,無解了啊o(╥﹏╥)o。
怎么整合呢?
2017-10-31
applicationContext.xml,這個名字是可以改的,不用固定,是否你WEB.XML里寫死了