Spring MVC web.xml 配置文件配置
来源:互联网 发布:梅雨知时节百度云 编辑:程序博客网 时间:2024/04/30 01:14
http://blog.csdn.net/wendellup/article/details/8270239
新建立一个Web Project, 含有web.xml
- <?xml version="1.0"encoding="UTF-8"?>
- <web-app id="WebApp_ID" version="2.4"xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/controllers.xml,/WEB-INF/service.xml</param-value>
- </context-param>
- <servlet>
- <servlet-name>dispatch</servlet>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/applicationContext.xml</param-value>
- </init-param>
- </servlet>
- <servlet-mapping>
- <servlet-name>dispatch</servlet-name>
- <servlet-pattern>*.*</servlet-pattern>
- </servlet-mapping>
- </web-app>
Spring分为多个文件进行分别的配置,其中在servlet-name中如果没有指定init-param属性,那么系统自动寻找的spring配置文件为[servlet-name]-servlet.xml。
当需要载入多个spring相关的配置文件时,首先加载ContextLoaderListener类,再指定context-param中指定多个spring配置文件,使用逗号分别隔开各个文件。为了使用方便可以将配置文件进行MVC式的分解,配置控制器Bean的配置文件放置在一个xml文件中,server的Bean放在service.xml文件中。
<servlet-mapping>指定的该servlet接管的url的行为,此处为了简便起见使用*.*,则表示在URL只要是在本机使用的任何request都是由该dispatchServlet来处理。
0 0
- [spring]Spring MVC web.xml 配置文件配置
- Spring MVC web.xml 配置文件配置
- Spring MVC web.xml配置
- Spring MVC 配置文件 web.xml文件详解
- spring-mvc-web.xml配置文件简单介绍
- spring mvc web.xml的配置
- spring mvc的web.xml的配置
- Spring MVC的web.xml配置详解
- spring mvc 的web.xml配置
- spring mvc中web.xml的配置
- Spring MVC的web.xml配置详解
- spring MVC 的 web.xml 配置讲解
- Spring MVC的web.xml配置详解
- Spring MVC的web.xml配置详解
- spring-mvc注解web.xml配置问题
- Spring MVC的web.xml配置详解
- Spring MVC的web.xml配置详解
- Spring MVC的web.xml配置详解
- 归并排序
- 聊聊Socket、TCP/IP、HTTP、FTP及网络编程
- 使用xutils实现多线程下载
- myibatis中出现“@P0' 附近有语法错误。”
- 基类RecyclerViewAdapter以及BaseViewHolder。减少适配器的重复代码量
- Spring MVC web.xml 配置文件配置
- 1058. A+B in Hogwarts (20)
- git rebase简介(基本篇)
- Jps常用命令整理
- iOS图片拉伸问题
- EntityFrameWork 从入门到熟悉(2)-简单增删改查
- GDOI最后一次终极模拟赛总结
- 数据库无法启动
- java基础笔记02