springmvc前端拦截相关
<!---->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
BeanNameUrlHandlerMapping、SimpleControllerHandlerAdapter是不需要注册的,DispatcherServlet默认会注册这两个Bean。DispatcherServlet启动时,会依次加载配置文件中所有的Resolver(包括MultipartResolver,LocaleResolver,ThemeResolver)、HandlerMappings、HandlerAdapter、HandlerExceptionResolver、ViewResolver,若没有,则会提供默认的相应配置
<!---->
HttpMessageConverter即由AnnotationMethodHandlerAdapter使用,HttpMessageConverter<T>接口负责将请求信息转换成T类型对象,将对象输出为响应信息.
AnnotationMethodHandlerAdapter默认已安装以下HttpMessageConverter
StringHttpMessageConverter、ByteArrayHttpMessageConverter、sourceHttpMessageConverter、XmlAwareFormHttpMessageConverter,如需要装配其它类型HttpMessageConverter,可在spring的web容器上下文中自定义AnnotationMethodHandlerAdapter
<!---->
org.springframework.web.servlet.view包下有好几个ViewResolver实现,其中默认采用InternalResourceViewResolver.
比如配置文件如下:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
<property name="prefix"><value>/WEB-INF/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean>
另外一种ViewResolver是ResourceBundleViewResolver,比如配置文件如下:
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename"><value>views-countries</value></property>
<property name="defaultParentView"><value>modelView</value></property>
</bean>
basename的配置表示将从classes目录下的views-countries.properties文件中获取资源,这样
我们可以很方便的实现国际化与本地化;
defaultParentView表示所有的view都将从modelView中继承而来,这和log4j的配置很类似.
其它的ViewResolver与上面分析的两种类同