mvc:interceptors namespace element initial commit
This commit is contained in:
parent
602118f1a3
commit
44fcc572a7
|
|
@ -5,10 +5,8 @@
|
|||
targetNamespace="http://www.springframework.org/schema/mvc"
|
||||
elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans"
|
||||
schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" />
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool"
|
||||
schemaLocation="http://www.springframework.org/schema/tool/spring-tool-3.0.xsd" />
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" />
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-3.0.xsd" />
|
||||
|
||||
<xsd:element name="annotation-driven">
|
||||
<xsd:annotation>
|
||||
|
|
@ -18,12 +16,28 @@
|
|||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="interceptors" minOccurs="0">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.web.servlet.HandlerInterceptor"><![CDATA[
|
||||
The ordered list of interceptors that intercept HTTP Servlet Requests mapped to Controllers.
|
||||
Interceptors allow a request to be pre/post processed before/after handling.
|
||||
Each inteceptor should be configured as an inner bean that implements the org.springframework.web.servlet.HandlerInterceptor interface.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="beans:bean" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="conversion-service" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.core.convert.ConversionService"><![CDATA[
|
||||
The bean name of the ConversionService that is to be used for type conversion during field binding.
|
||||
This attribute is not required, and only needs to be specified explicitly if custom converters need to be configured.
|
||||
If not specified, a DefaultConversionService is registered that contains converters to/from standard JDK types.
|
||||
If not specified, a default FormattingConversionService is registered that contains converters to/from standard JDK types.
|
||||
In addition, full support for date/time formatting will be installed if the Joda Time library is present on the classpath.
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
|
|
@ -46,7 +60,7 @@
|
|||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,19 @@ public class MvcNamespaceTests {
|
|||
assertTrue(container.getBean(TestValidator.class).validatorInvoked);
|
||||
assertFalse(handler.recordedValidationError);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterceptors() throws Exception {
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(container);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("mvc-config-interceptors.xml", getClass()));
|
||||
assertEquals(4, container.getBeanDefinitionCount());
|
||||
DefaultAnnotationHandlerMapping mapping = container.getBean(DefaultAnnotationHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
assertEquals(0, mapping.getOrder());
|
||||
AnnotationMethodHandlerAdapter adapter = container.getBean(AnnotationMethodHandlerAdapter.class);
|
||||
assertNotNull(adapter);
|
||||
assertNotNull(container.getBean(FormattingConversionServiceFactoryBean.class));
|
||||
}
|
||||
|
||||
@Controller
|
||||
public static class TestController {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
|
||||
|
||||
<mvc:annotation-driven>
|
||||
<mvc:interceptors>
|
||||
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
|
||||
<bean class="org.springframework.web.servlet.i18n.ThemeChangeInterceptor" />
|
||||
</mvc:interceptors>
|
||||
</mvc:annotation-driven>
|
||||
|
||||
</beans>
|
||||
Loading…
Reference in New Issue