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"
4 xmlns:p="http://www.springframework.org/schema/p"
5 xmlns:mvc="http://www.springframework.org/schema/mvc"
6 xmlns:context="http://www.springframework.org/schema/context"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
9 http://www.springframework.org/schema/context
10 http://www.springframework.org/schema/context/spring-context-4.2.xsd
11 http://www.springframework.org/schema/mvc
12 http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
13
14 <!-- <bean id="login" class="com.mvc.LoginController"></bean>
15 <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
16 <property name="mappings">
17 <props>
18 <prop key="login.spring">login</prop>
19 </props>
20 </property>
21 </bean> -->
22
23 <mvc:annotation-driven/><!-- 启动注解驱动 -->
24
25 <!--下一步启用自动扫描: -->
26 <context:component-scan base-package="com.mvc"></context:component-scan>
27
28 <!-- ViewResolver视图解析器 用于将返回的ModelAndView对象进行分离 :-->
29 <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
30 <property name="viewClass"
31 value="org.springframework.web.servlet.view.JstlView"></property>
32 <property name="prefix" value="/"></property>
33 <property name="suffix" value=".jsp"></property>
34 </bean>
35
36 <!-- jackson固定配置 :-->
37 <bean
38 class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
39 <property name="messageConverters">
40 <list>
41 <ref bean="mappingJacksonHttpMessageConverter" />
42 </list>
43 </property>
44 </bean>
45
46 <bean id="mappingJacksonHttpMessageConverter"
47 class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
48 <property name="supportedMediaTypes">
49 <list>
50 <value>text/html;charset=UTF-8
</value>
51 </list>
52 </property>
53 </bean>
54 </beans>
转载于:https://www.cnblogs.com/xjpu/p/6597677.html
转载请注明原文地址: https://win8.8miu.com/read-1542850.html