springmvc-servlet.xml文件配置如下:
欢迎加我的qq技术群425783133
<?xml version=
"1.0"
encoding=
"UTF-8"
?>
02 | <beans xmlns= "http://www.springframework.org/schema/beans" |
03 | xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:p= "http://www.springframework.org/schema/p" |
04 | xmlns:context= "http://www.springframework.org/schema/context" |
05 | xmlns:mvc= "http://www.springframework.org/schema/mvc" xmlns:util= "http://www.springframework.org/schema/util" |
06 | xsi:schemaLocation="http: //www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd |
07 | http: //www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd |
08 | http: //www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd |
09 | http: //www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> |
10 | |
11 | <mvc:annotation-driven /> |
12 | |
13 | <context:component-scan base- package = "com.springMVC" ></context:component-scan> |
14 | <bean id= "validator" class = "org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" ></bean> |
15 | |
16 | <!-- 定义视图解析器为jsp --> |
17 | <bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver" |
18 | p:prefix= "/views/" |
19 | p:suffix= ".jsp" |
20 | p:order= "2" ></bean> |
21 | <!-- 定义视图解析器为tiles --> |
22 | <bean id= "viewResolver" class = "org.springframework.web.servlet.view.InternalResourceViewResolver" |
23 | p:viewClass= "org.springframework.web.servlet.view.tiles.TilesJstlView" |
24 | p:order= "1" > |
25 | </bean> |
26 | |
27 | <bean id= "tilesConfigurer" class = "org.springframework.web.servlet.view.tiles.TilesConfigurer" > |
28 | <property name= "definitions" > |
29 | <list> |
30 | <value>/WEB-INF/config/tiles-defs.xml</value> |
31 | </list> |
32 | </property> |
33 | </bean> |
34 | </beans> |