<?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 基本配置
原文:https://www.cnblogs.com/hzb462606/p/9142656.html