<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
- DispatcherServlet application context for the Countries web tier.
-->
<beans>
<!-- ========================= MAPPING DEFINITIONS ========================= -->
<!--
- 使用ResourceBundleViewResolver代替默认内部的资源视图解析器(InternalResourceViewResolver)声明绑定的视图映射.
- 从本地类路径文件"views_appname"获取视图映射,例如.
- "/WEB-INF/classes/views-countries.properties" 或 "/WEB-INF/classes/views-countries_fr.properties".
-
- 由控制器(controllers)返回的视图的名字将被在各自的属性文件里解析,允许任意的在名字-资源间的映射
- 我们使用"defaultParentView" 属性. 所有视图的定义将默认继承"modelView"视图定义的属性.
-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views-countries"/>
<property name="defaultParentView" value="modelView"/>
</bean>
<!--
- 我们再次指定保存在cookies里的现场和主题(theme).
- 他们被保存在一个会话里(Session). 默认的解析器不允许在闲置时更改他们.
-->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"/>
<bean id="themeResolver" class="org.springframework.web.servlet.theme.CookieThemeResolver">
<property name="defaultThemeName" value="spring"/>
</bean>
<!--
- 使用SimpleUrlHandlerMapping代替 BeanNameUrlHandlerMapping声明URL handler 映射.
-->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor"/>
<ref bean="themeChangeInterceptor"/>
</list>
</property>
<property name="mappings">
<props>
<prop key="/home.htm">countriesController</prop>
<prop key="/config.htm">countriesController</prop>
<prop key="/copy.htm">countriesController</prop>
<prop key="/main/home.htm">countriesController</prop>
<prop key="/main/detail.htm">countriesController</prop>
<prop key="/main/countries.xls">countriesController</prop>
<prop key="/main/countries.pdf">countriesController</prop>
<prop key="/notfound.htm">errorsController</prop>
</props>
</property>
</bean>
<!-- ========================= CONTROLLER DEFINITIONS ========================= -->
<!--
- 拦截器将会预先操控(pre-handle)该servlet中任何请求,而不管哪个controller已经映射于该请求
- 我们使用两个内建的拦截器来检查使用者的现场(locale)或主题(theme)更改请求.
- 第三个拦截器在该演示中指定. 它使视图很容易的了解到配置已经被检测过了
- 同时会了解是否一份数据库的数据拷贝可以提供给使用者.
-->
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
<bean id="themeChangeInterceptor" class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"/>
<!-- 一般用法,使用multi-action controller for errors -->
<bean id="errorsController" class="org.springframework.samples.countries.web.ErrorsController">
<property name="methodNameResolver">
<bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/notfound.htm">handleHttp404</prop>
</props>
</property>
</bean>
</property>
</bean>
<!-- Application specific multi-action controller -->
<bean id="countriesController" class="org.springframework.samples.countries.web.CountriesController">
<property name="methodNameResolver">
<bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/home.htm">handleHome</prop>
<prop key="/config.htm">handleConfig</prop>
<prop key="/copy.htm">handleCopy</prop>
<prop key="/main/home.htm">handleMain</prop>
<prop key="/main/detail.htm">handleDetail</prop>
<prop key="/main/countries.xls">handleExcel</prop>
<prop key="/main/countries.pdf">handlePdf</prop>
</props>
</property>
</bean>
</property>
<property name="countryService" ref="countryService"/>
</bean>
</beans>
|