以下配置可直接使用,只需更改包名。关于内部标签的解释及用法,都以注解形式在代码内部说明。个人原创,转载需注明出处。1,web. 1 <??> 2 <web-app ="http://www.w3.org/2001/ 3 ="http:// ...
以下配置可直接使用,只需更改包名。
关于内部标签的解释及用法,都以注解形式在代码内部说明。个人原创,转载需注明出处。
1,web.
1 <??> 2 <web-app ="http://www.w3.org/2001/ 3 ="http://java.sun.com/ 4 xsi:schemaLocation="http://java.sun.com/ 5 id="WebApp_ID" version="3.0"> 6 <display-name>CRM</display-name> 7 <welcome-file-list> 8 <welcome-file>login.jsp</welcome-file> 9 </welcome-file-list>10 11 <!-- 以下配置在spring文档中可通过搜索web-app获得(不包含中文编码器) -->12 13 <!-- spring的配置文件,默认放在WEB-INF下。这里将其放在src下,故需要如下配置 -->14 <context-param>15 <param-name>contextConfigLocation</param-name>16 <param-value>classPath:appliationContext.</param-value>17 </context-param>18 19 <!-- 启动web时加载spring的配置文件 -->20 <listener>21 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>22 </listener>23 24 <!-- 添加springMVC支持,单独springMVC时也需要在web.-->25 <servlet>26 <servlet-name>dispatcher</servlet-name>27 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>28 <init-param>29 <param-name>contextConfigLocation</param-name>30 <param-value>classPath:spring-mvc.</param-value>31 </init-param>32 <!-- 启动web时就加载springmvc的servlet,即启动时就加载springmvc的配置文件 -->33 <load-on-startup>1</load-on-startup>34 <!-- 可异步执行,最好都配上,项目会比较流畅 -->35 <!-- 配置异步时若报错,因为是3.0新特征,可将2.5改为3.0即可 -->36 <async-supported>true</async-supported>37 </servlet>38 <servlet-mapping>39 <servlet-name>dispatcher</servlet-name>40 <!-- 拦截所有以.do结尾的请求,后续的业务代码请求后缀都将以.do结尾(个人习惯) -->41 <url-pattern>*.do</url-pattern>42 </servlet-mapping>43 44 <!-- 中文编码器,防止出现中文乱码 -->45 <filter>46 <filter-name>characterEncodingFilter</filter-name>47 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>48 <init-param>49 <param-name>encoding</param-name>50 <param-value>UTF-8</param-value>51 </init-param>52 </filter>53 <filter-mapping>54 <filter-name>characterEncodingFilter</filter-name>55 <!-- 所有请求都必须通过该校验 -->56 <url-pattern>/*</url-pattern>57 </filter-mapping>58 59 </web-app>
原标题:Spring+SpringMVC+Mybaties整合之配置文件如何配置及内容解释
关键词:Spring
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。