首页 > 编程语言 > 详细

spring-mvc.xml中的配置

时间:2016-03-14 11:49:43      阅读:225      评论:0      收藏:0      [点我收藏+]
 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>

 

spring-mvc.xml中的配置

原文:http://www.cnblogs.com/MrzhangKk/p/5274892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!