-
Notifications
You must be signed in to change notification settings - Fork 175
/
spring-mvc-servlet.xml
135 lines (116 loc) · 5.58 KB
/
spring-mvc-servlet.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<!-- 扫描注入com.fengjing.framework.springmvc包下仅包含@Controller注解的bean -->
<context:component-scan base-package="com.fengjing.framework.springmvc">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<mvc:annotation-driven />
<!-- 用于将实体转化为xml格式的数据 -->
<bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller" id="jaxbMarshaller">
<property name="classesToBeBound">
<list>
<value>com.fengjing.framework.springmvc.model.Contact</value>
<value>com.fengjing.framework.springmvc.model.Contacts</value>
</list>
</property>
</bean>
<!-- 定义视图资源文件名称 -->
<bean id="resourceBundleViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views"></property>
<property name="order" value="0" />
</bean>
<!-- 表单校验国际化信息资源文件 -->
<bean class="org.springframework.context.support.ResourceBundleMessageSource" id="messageSource">
<property name="basenames">
<list>
<value>messages</value>
<value>customer</value>
<value>security_messages</value>
</list>
</property>
</bean>
<!-- 处理jsp视图 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 使用SimpleUrlHandlerMapping来处理SpringMVC -->
<!-- 该配置的信息是当请求地址为/simpleUrl.do时去寻找为simpleUrlController的bean处理 -->
<bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true"></property>
<property name="mappings">
<props>
<prop key="/simpleurl.do">simpleUrlController</prop>
</props>
</property>
</bean>
<!-- velocity视图解析 -->
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/velocity/" />
<property name="configLocation" value="/WEB-INF/velocity.properties"></property>
</bean>
<bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="/" />
<property name="suffix" value=".vm" />
<property name="exposeSpringMacroHelpers" value="true" />
</bean>
<!-- freeMarker视图解析 -->
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/freemarker/" />
</bean>
<bean id="freeMarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".ftl" />
<property name="exposeSpringMacroHelpers" value="true" />
</bean>
<!-- SpringMVC错误异常输出 -->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="com.fengjing.framework.springmvc.exception.handling.GenericException">
GenericExceptionPage
</prop>
<prop key="java.lang.Exception">error</prop>
</props>
</property>
</bean>
<!-- 按bean的名字去解析 -->
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
<!--SpringMVCHandlerMapping 取Controller的name部分为请求地址-->
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" />
<!--Spring MVC Form Handling-->
<bean class="com.fengjing.framework.springmvc.form.handling.controller.SpringMVCformCustomerController">
<property name="formView" value="CustomerForm" />
<property name="successView" value="CustomerSuccess" />
<property name="validator">
<bean class="com.fengjing.framework.springmvc.form.handling.validator.CustomerValidator" />
</property>
</bean>
<!-- Spring MVC Handling Multipage Forms With AbstractWizardFormController -->
<bean class="com.fengjing.framework.springmvc.handling.multipage.forms.controller.WelcomeController" />
<bean class="com.fengjing.framework.springmvc.handling.multipage.forms.controller.UserController" >
<property name="pages">
<list>
<!-- follow sequence -->
<value>Page1Form</value> <!-- page1 -->
<value>Page2Form</value> <!-- page2 -->
<value>Page3Form</value> <!-- page3 -->
</list>
</property>
<property name="validator">
<bean class="com.fengjing.framework.springmvc.handling.multipage.forms.validator.UserValidator" />
</property>
</bean>
</beans>