maven项目管理web层中web.xml

在创建maven项目时,创建XXX-web子工程时,会发生报错现象(主要是使用eclipse编译器),右击项目,选择javaEEtools-》选择第二个子菜单generate deployment descriptor Stub,即可自动生成webapp下的web.xml文件
在web子工程主要需要配置
		Web.xm
struts.xml文件(struts核心过滤器)
<!-- 配置struts2的核心过滤器 -->
  <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  
  <filter-mapping>
  	<filter-name>struts2</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping>


lo4j.properties文件
applicationContext.xml文件Spring 框架的监听器
<!-- 配置完spring监听器还需要配置指定spring配置文件的位置 -->
  <!-- 通过上下文参数指定spring配置文件的位置 -->
  <context-param>
  	<param-name>contextConfigLocation</param-name>
  	<param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  	<!-- 配置spring框架的监听器 -->
  <listener>
  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>




配置hibernate延迟加载
<!-- 配置过滤器,解决hibernate延迟加载 -->
  <filter>
  	<filter-name>openSessionInView</filter-name>
  	<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>openSessionInView</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping>

猜你喜欢

转载自blog.csdn.net/xuan_lu/article/details/79834423