毕业项目SSM框架配置文件之web.xml

本文详细解析了SSM(Spring、SpringMVC、MyBatis)框架中核心配置文件web.xml的作用和配置步骤,包括Servlet、Filter、DispatcherServlet、监听器等关键元素的设置,旨在帮助读者理解SSM项目的启动流程和配置原理。
摘要由CSDN通过智能技术生成
 <display-name></display-name>	
  <welcome-file-list>
    <welcome-file>user/preIndex.action</welcome-file>
  </welcome-file-list>
  
  	<!-- 配置spring前端控制器 -->
  <servlet>
  	<servlet-name>springmvc</servlet-name>
  	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  						<!-- 设置spring配置文件的路径。如果不配置,默认找/WEB-INF/springmvc-servlet.xml该文件。 -->
  	<init-param>
  		<param-name>contextConfigLocation</param-name>
  		<param-value>classpath:applicationContext.xml</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>springmvc</servlet-name>
  	<url-pattern>*.action</url-pattern>
  </servlet-mapping>

	<!-- spring配置 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<!-- Log4j配置开始 -->
	<context-param> 
   		<param-name>log4jConfigLocation</param-name> 
   		<param-value>WEB-INF/log4j.properties</param-value> 
	</context-param> 
	<context-param> 
   		<param-name>log4jRefreshInterval</param-name> 
   		<param-value>60000</param-value> 
	</context-param> 
	<!-- 需要添加spring-web.jar包,否则用发生错误信息 -->
	<listener> 
   		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> 
	</listener>
  <!-- Log4j配置结束 -->
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
SSM框架中,web.xml文件是用来配置Web应用程序的部署描述符。下面是一个示例的SSM框架web.xml配置: ```xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- 配置DispatcherServlet --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- 配置DispatcherServlet的映射路径 --> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 配置Spring的配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-config.xml</param-value> </context-param> <!-- 配置Spring监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配置字符编码过滤器 --> <filter> <filter-name>encodingFilter</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>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> ``` 以上是一个简单的SSM框架web.xml配置示例,其中主要配置了DispatcherServlet、Spring的配置文件、Spring监听器和字符编码过滤器等。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值