1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" 4 xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" 5 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans 7 http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 8 http://www.springframework.org/schema/context 9 http://www.springframework.org/schema/context/spring-context-3.2.xsd 10 http://www.springframework.org/schema/aop 11 http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 12 http://www.springframework.org/schema/tx 13 http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 14 http://www.springframework.org/schema/mvc 15 http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 16 http://www.springframework.org/schema/context 17 http://www.springframework.org/schema/context/spring-context-3.2.xsd"> 18 19 <!-- 使Spring支持自动检测组件,如注解的Controller --> 20 <context:component-scan base-package="cn.smart.webapp.controller" /> 21 <context:annotation-config /> 22 23 24 <!--避免IE执行AJAX时,返回JSON出现下载文件 --> 25 <bean id="mappingJacksonHttpMessageConverter" 26 class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> 27 <property name="supportedMediaTypes"> 28 <list> 29 <value>text/html;charset=UTF-8</value> 30 </list> 31 </property> 32 </bean> 33 34 35 <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> 36 <bean 37 class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> 38 <property name="messageConverters"> 39 <list> 40 <ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 --> 41 </list> 42 </property> 43 </bean> 44 45 46 <!-- jsp视图解析器 --> 47 <bean id="jspViewResolver" 48 class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 49 <property name="viewClass" 50 value="org.springframework.web.servlet.view.JstlView" />
//下面value中的是jsp所在的路径 51 <property name="prefix" value="WEB-INF/view/" /> 52 <property name="suffix" value=".jsp" /> 53 54 </bean> 55 </beans>