1. 程式人生 > >ssm框架中,web專案中spring-mvc.xml解析

ssm框架中,web專案中spring-mvc.xml解析

spring-mvc.xml配置檔案主要用於配置SpringMVC檢視解析器、控制器、部分靜態資源等。

type:Spring Bean Configuration File

<?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:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.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.3.xsd">

	<!--網站跳轉控制 -->

	<!-- 掃描controller -->
	<context:component-scan base-package="com.atguigu.crud.controller"></context:component-scan>

	<!-- 檢視解析器 -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<!-- 配置jsp路徑的字首 -->
		<property name="prefix" value="/WEB-INF/views/" />
		<!-- 配置jsp路徑的字尾 -->
		<property name="suffix" value=".jsp" />
	</bean>

	<!--兩個標準  -->
	<!--將springmvc不能處理的請求交給tomcat,指使用者對靜態資源的請求  -->
	<mvc:default-servlet-handler/>
	<!--支援springmvc一些更高階的功能,jsr303校驗,快捷的ajax。。。。對映動態請求  -->
	<mvc:annotation-driven></mvc:annotation-driven>
</beans>