spring MVC配置详解
来源:互联网 发布:mac 手写 编辑:程序博客网 时间:2024/06/08 18:13
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>jd7</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- mybatis --> <context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-mybatis.xml</param-value></context-param><!-- 监听 --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener> <!-- spring MVC配置 --> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- ====================================== --> <!-- 可以自定义servlet.xml配置文件的位置和名称,默认为WEB-INF目录下,名称为[<servlet-name>]-servlet.xml,如spring-servlet.xml <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> 默认 </init-param> --> <!-- ====================================== --> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping><servlet-name>spring</servlet-name><url-pattern>/</url-pattern></servlet-mapping> <!-- 编码过滤器 --> <!-- POST中文乱码解决方案 --> <filter><filter-name>characterEncodingFilter</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>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-app>
spring-servlet.xml配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <!-- 启用spring mvc 注解 --> <mvc:default-servlet-handler/> <!-- ****改包名**** --><!-- 设置使用注解的类所在的jar包 --> <context:component-scan base-package="com.cng.controller"/> <context:component-scan base-package="com.cng.service"/> <context:component-scan base-package="com.cng.dao"/><mvc:annotation-driven/><!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/> </beans>参考文献:http://www.cnblogs.com/superjt/p/3309255.html
0 0
- Spring MVC配置详解
- Spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- spring MVC配置详解
- 字典序
- jdbc学习总结五之批处理
- php 面试题
- 事物
- 自己设计系统之间的通信协议
- spring MVC配置详解
- jquery获取当前元素的标签类型
- Struts2访问ServletAPI(向JSP内置对象request,session,Application传值)
- 关于字符串池的概念以及解释
- C#解析Json值中含数组
- 【CS229 Lecture notes, Andrew Ng 】阅读笔记(持续更新中...)
- 使用VS2013编译Caffe源码(不带GPU支持)步骤
- C++——STL所有算法介绍
- 一起写RPC框架(九)RPC服务提供端一--服务端的基本代码结构