maven專案管理web層中web.xml
阿新 • • 發佈:2019-01-25
在建立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>