springMVC的简单配置
2016-03-30 21:49
363 查看
今天自己没事就学习一下关于springMVC的配置。很简单的记录一下成果,以后也可以随时翻看
1.web.xml配置。
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<!--配置dispactcherServlet -->
<servlet>
<servlet-name>testSpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/springmvc.xml</param-value>
</init-param>
</servlet>
<!-- 配置servlet 拦截的url类型 -->
<servlet-mapping>
<servlet-name>testSpringMVC</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 配置初始化加载的xml文件
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:testSpringMVC.xml</param-value>
</context-param>
-->
<!--登陆的首页:即第一个访问的网页 -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2.springMVC配置文件。
<!-- 启用spring mvc 注解 -->
<context:annotation-config />
<!-- 使用MVC的注解驱动可以代替注解映射器以及注解适配器
默认加载很多参数的绑定:比如json的转接器
-->
<mvc:annotation-driven></mvc:annotation-driven>
<!--配置注解扫描的范围 -->
<context:component-scan base-package="com.ylIntenet.testSpringMVC.controller"></context:component-scan>
</beans>
1.web.xml配置。
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<!--配置dispactcherServlet -->
<servlet>
<servlet-name>testSpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/springmvc.xml</param-value>
</init-param>
</servlet>
<!-- 配置servlet 拦截的url类型 -->
<servlet-mapping>
<servlet-name>testSpringMVC</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 配置初始化加载的xml文件
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:testSpringMVC.xml</param-value>
</context-param>
-->
<!--登陆的首页:即第一个访问的网页 -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2.springMVC配置文件。
<!-- 启用spring mvc 注解 -->
<context:annotation-config />
<!-- 使用MVC的注解驱动可以代替注解映射器以及注解适配器
默认加载很多参数的绑定:比如json的转接器
-->
<mvc:annotation-driven></mvc:annotation-driven>
<!--配置注解扫描的范围 -->
<context:component-scan base-package="com.ylIntenet.testSpringMVC.controller"></context:component-scan>
</beans>
相关文章推荐
- Spring Ioc set注入
- Spring学习——(五)Spring中数据源的配置
- 《深入理解java虚拟机》读书笔记:对象的内存布局
- JPA hibernate spring repository pgsql java 工程(三):数据表分区与自动创建:策略
- Java中的“流”的flush方法
- mysql编码和Java编码相应一览表
- java 中易混淆的知识点1
- Java ActiveMQ 讲解(一)理解JMS 和 ActiveMQ基本使用
- idea破解方案之搭建本地破解
- Java数据库连接池的几种配置方法(以MySQL数据库为例)
- SPRING JMS 整合ACTIVEMQ
- java设置classpath,path和java_home的作用
- Struts2框架提供的结果类型
- 使用Struts2+Hibernate开发学生信息管理系统
- 浅谈java equals和“==”区别
- Spring IOC三种注入方式(接口注入、setter注入、构造器注入)
- java 中的遇到的问题1
- StringTokenizer类的使用方法(Java)
- 关于Java是传值还是传引用的笔记
- eclipse快捷键