1. 程式人生 > >Maven 默認 SpringMVC-servlet.xml 基本配置

Maven 默認 SpringMVC-servlet.xml 基本配置

視圖解析 scan version suffix prope 精確 設置 schema sources

<?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:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation
=" 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 掃描器,指定DispatcherServlet去掃描當前包名下的所有類, base-package屬性不能精確到類級別,只能到包級別 --> <context:component-scan base-package="org.sprigmvc.pag"/> <context:component-scan base-package="org.sprigmvc.dao"/> <!-- 視圖解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean>
<!-- 配置註解驅動:與以下靜態資源不攔截配套使用 --> <mvc:annotation-driven/> <!-- 靜態資源不攔截(可以設置多個): mapping為請求源頭,location為請求指向位置,當mapping下的目錄發送請求時,指向location的目錄,不攔截請求。--> <mvc:resources location="/staticRescoures/" mapping="/staticRescoures/**" />
</beans>

Maven 默認 SpringMVC-servlet.xml 基本配置