SpringMvc+MyBtis第三季
对于mybatis-config.xml的配置根据用户对mybatis的使用和封装的不同的接收结果类的不同进行响应的配置,这里我就不多说了,根据自己的需求去配置了。
web.xml的配置,相信大家已经配置了这么多的servlet了 应该已经了如指掌了吧。
但是这里我要重点的提一句,我们要先通过contextConfigLocation进行Spring配置文件的添加
------添加一个Spring上下文监听器
<!-- 上下文Spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
--------对Spring配置文件的加载
<!-- 配置文件位置,默认为/WEB-INF/applicationContext.xml -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/application*.xml</param-value>
</context-param>
-------添加字符过滤我就不多说了
-------重点:添加Serlvet控制调度类,并载入SpringMvc配置文件
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/springmvc-dispatcher.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>