spring mvc spring-mvc.xml 配置

说明

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
		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-4.0.xsd">

	<!-- 组件扫描 -->
	<context:component-scan base-package="com.atguigu.springmvc"></context:component-scan>
	
	<!-- 视图解析器 -->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/views/"></property>
		<property name="suffix" value=".jsp"></property>
	</bean>
	<!-- 
		将在 SpringMVC 上下文中定义一个 DefaultServletHttpRequestHandler,
		它会对进入 DispatcherServlet 的请求进行筛查,如果发现是没有经过映射的请求,
		就将该请求交由 WEB 应用服务器默认的 Servlet 处理,如果是由映射的请求,才由 DispatcherServlet 继续处理
		
		如果web应用服务器的默认的Serlvet的名字不叫"default",则需要通过default-servlet-name来进行指定.
		
		配置了default-serlvet-handler后,RequestMapping的映射会失效,需要加上annotation-driven的配置。		
	 -->
	<mvc:default-servlet-handler />
	<!--  -->
	<mvc:annotation-driven/>
</beans>

  

猜你喜欢

转载自www.cnblogs.com/liubosong/p/12034847.html