关于spring-springMVC-mybatis框架,web.xml的配置
<!--加载优先级context-param大于listener大于filter大于servlet-->
<!-- ********************* 根目录设置 start ********************* -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webName.root</param-value>
</context-param>
<!-- ********************* 根目录设置 end ********************* -->
<!-- ********************* spring配置 start ********************* -->
<!--spring配置有俩种方式-->
<!--第一种 配置监听spring-->
<!--该配置方式默认去找classpath下的application-Context.xml,若加上第二种方式后,则根据配置路径加载spring配置文件-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--第二种-->
<!--路径跟具实际情况配置 classpath相当于web-info/classes/-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationcontext.xml</param-value>
</context-param>
<!-- ********************* spring配置 end *********************-->
<!-- ********************* Log4j配置 start ********************* -->
<!-- spring加载log4j的监听 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<!-- 3000表示 开一条watchdog线程每60秒扫描一下配置文件的变化;这样便于日志存放位置的改变 -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>3000</param-value>
</context-param>
<!-- ********************* Log4j配置 end ********************* -->
<!-- ********************* 配置spring字符编码为utf-8 start *********************-->
<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>
<!--********************* 配置spring字符编码为utf-8 end *********************-->
<!--********************* springmvc配置 start *********************-->
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!--路径跟具实际情况配置 classpath相当于web-info/classes/-->
<param-value>classpath:config/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>
<!-- ********************* springmvc配置 end ********************* -->
<!-- ********************* 欢迎页面 start ********************* -->
<welcome-file-list>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- ********************* 欢迎页面 end ********************* -->
<!-- ********************* 错误页面配置 start *********************-->
<!-- 常用的404和500页面 -->
<error-page>
<error-code>404</error-code>
<location>/building.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.html</location>
</error-page>
<!-- ********************* 错误页面配置 end *********************-->