SpringMVC之web.xml基本配置
2017-05-17 11:49
330 查看
web.xml文件的作用:
1.指定webapp的名称
<display-name>SpringMVCDemo</display-name>
2.初始化上下文参数,装载spring配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
解释:
<param-name></param-name>指定上下文名称contextConfigLocation。
contextConfigLocation作用:指定要加载的的spring文件
<param-value></param-value> spring配置文件的路径,如果多个配置文件可以用逗号分隔。
配置spring监听器
<listener>
<listener-class>org.springframeword.web.context.ContextLoaderListener</listener-class>
</listener>
3.注册Dispatecher-Servlet,load-on-startup标示是否在启动时候就加在servlet,加载优先级
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-calss>
<load-on-startup>1</load-on-startup>
</servlet>
将DispatcherServlet映射到“/”,拦截所有请求
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</setvlet-mapping>
1.指定webapp的名称
<display-name>SpringMVCDemo</display-name>
2.初始化上下文参数,装载spring配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
解释:
<param-name></param-name>指定上下文名称contextConfigLocation。
contextConfigLocation作用:指定要加载的的spring文件
<param-value></param-value> spring配置文件的路径,如果多个配置文件可以用逗号分隔。
配置spring监听器
<listener>
<listener-class>org.springframeword.web.context.ContextLoaderListener</listener-class>
</listener>
3.注册Dispatecher-Servlet,load-on-startup标示是否在启动时候就加在servlet,加载优先级
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-calss>
<load-on-startup>1</load-on-startup>
</servlet>
将DispatcherServlet映射到“/”,拦截所有请求
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</setvlet-mapping>
相关文章推荐
- springmvc基本web.xml配置和xxxx-sevlet.xml配置简介
- springmvc 项目:web.xml基本配置
- springmvc 项目:web.xml基本配置
- web.xml文件的作用及基本配置
- web.xml文件的作用和基本配置
- web.xml文件的作用及基本配置
- jsp web.xml文件的作用及基本配置
- jsp web.xml文件的作用及基本配置
- jsp web.xml文件的作用及基本配置
- jsp web.xml文件的作用及基本配置
- 理解Struts在web.xml中的基本配置
- JavaWeb工程中web.xml基本配置
- web.xml文件的作用及基本配置
- web.xml文件的作用及基本配置
- springmvc之web.xml配置
- web.xml文件的作用及基本配置
- web.xml文件的作用及基本配置
- jsp web.xml文件的作用及基本配置
- web.xml文件基本配置讲解
- JavaWeb工程中web.xml基本配置