上一篇文档初步搭建了一个springmvc的web工程,现在要来实现第二步咯。将登录校验整合到项目中,我用的是spring 3.0.2的版本,所以这里的登录用了security来处理。不多说,上代码。

web.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
 5     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 6 
 7     <!-- spring核心监听器 配置ContextLoaderListener表示,该工程要以spring的方式启动。启动时会默认在/WEB-INF目录下查找 applicationContext.xml作为spring容器的配置文件 -->
 8     <listener>
 9         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
10     </listener>
11 
12     <!-- 配置DispatcherServlet表示,该工程将采用springmvc的方式。启动时也会默认在/WEB-INF目录下查找XXX-servlet.xml作为配置文件,XXX就是DispatcherServlet的名字 -->
13     <!-- spring-servlet.xml -->
14     <servlet>
15         <servlet-name>spring</servlet-name>
16         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
17     </servlet>
18     <servlet-mapping>
19         <servlet-name>spring</servlet-name>
20         <url-pattern>/</url-pattern>
21     </servlet-mapping>
22     
23     <!-- spring security -->  
24     <filter>    
25         <filter-name>springSecurityFilterChain</filter-name>    
26         <filter-class>org.springframework.web.filter.DelegatingFilterProxy    
27         </filter-class>    
28     </filter>    
29      
30     <filter-mapping>    
31         <filter-name>springSecurityFilterChain</filter-name>    
32         <url-pattern>/*</url-pattern>    
33     </filter-mapping>  
34       
35     <context-param>  
36         <param-name>contextConfigLocation</param-name>  
37         <param-value>classpath*:applicationContext-security.xml</param-value>  
38     </context-param>  
39     
40     <!-- 欢迎页 -->
41     <welcome-file-list>
42         <welcome-file>login.jsp</welcome-file>
43     </welcome-file-list>
44 </web-app>
web.xml

相关文章:

  • 2021-04-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-06-20
  • 2022-02-07
  • 2021-10-29
猜你喜欢
  • 2021-04-03
  • 2021-04-03
  • 2021-05-27
  • 2022-12-23
  • 2021-11-02
  • 2022-01-21
  • 2021-11-20
相关资源
相似解决方案