<?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.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 1.配置前端控制器放行靜態資源(html/css/js等,否則靜態資源將無法訪問) --> <mvc:default-servlet-handler/> <!-- 2.配置注解驅動,用於識別注解(比如@Controller) --> <mvc:annotation-driven></mvc:annotation-driven> <!-- 3.配置需要掃描的包:spring自動去掃描 base-package 下的類, 如果掃描到的類上有 @Controller、@Service、@Component等注解, 將會自動將類注冊為bean --> <context:component-scan base-package="com.tsvv.controller"> </context:component-scan> <!-- 4.配置內部資源視圖解析器 prefix:配置路徑前綴 suffix:配置文件后綴 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/pages/"/> <property name="suffix" value=".jsp"/> </bean> </beans>