Support Java and MVC namespace view resolution config
This commit improves and completes the initial MVC namespace view resolution implementation. ContentNegotiatingViewResolver registration is now also supported. Java Config view resolution support has been added. FreeMarker, Velocity and Tiles view configurers are registered depending on the classpath thanks to an ImportSelector. For both, a default configuration is provided and documented. Issue: SPR-7093
This commit is contained in:
committed by
Rossen Stoyanchev
parent
a26b1ef8d9
commit
cc7e8f5558
@@ -0,0 +1,26 @@
|
||||
<?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:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
|
||||
<mvc:annotation-driven />
|
||||
|
||||
<mvc:view-resolution>
|
||||
|
||||
<mvc:content-negotiating use-not-acceptable="true">
|
||||
<mvc:default-views>
|
||||
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
|
||||
</mvc:default-views>
|
||||
</mvc:content-negotiating>
|
||||
|
||||
<mvc:jsp />
|
||||
<mvc:freemarker />
|
||||
<mvc:velocity />
|
||||
|
||||
</mvc:view-resolution>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="myViewResolver2"
|
||||
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
|
||||
<property name="prefix">
|
||||
<value>/WEB-INF/pages/</value>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<value>.jsp</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||
<property name="mediaTypes">
|
||||
<value>
|
||||
xml=application/rss+xml
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<mvc:view-resolution>
|
||||
|
||||
<mvc:content-negotiating manager="contentNegotiationManager" use-not-acceptable="true">
|
||||
<mvc:default-views>
|
||||
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
|
||||
</mvc:default-views>
|
||||
</mvc:content-negotiating>
|
||||
|
||||
<mvc:jsp prefix="/WEB-INF/" suffix=".jsp" />
|
||||
<mvc:bean-name />
|
||||
<mvc:tiles definitions="/org/springframework/web/servlet/resource/tiles/tiles1.xml" />
|
||||
<mvc:freemarker prefix="" suffix=".ftl" template-loader-paths="/" />
|
||||
<mvc:velocity prefix="" suffix=".vm" resource-loader-path="/" />
|
||||
|
||||
<bean id="myViewResolver1" class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
|
||||
<property name="prefix">
|
||||
<value>/WEB-INF/pages/</value>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<value>.jsp</value>
|
||||
</property>
|
||||
</bean>
|
||||
<ref bean="myViewResolver2" />
|
||||
|
||||
</mvc:view-resolution>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<mvc:view-resolution>
|
||||
|
||||
<mvc:jsp prefix="/WEB-INF/" suffix=".jsp" />
|
||||
|
||||
<mvc:bean-name />
|
||||
|
||||
<mvc:tiles definitions="/org/springframework/web/servlet/resource/tiles/tiles1.xml,/org/springframework/web/servlet/resource/tiles/tiles2.xml"
|
||||
check-refresh="true" />
|
||||
|
||||
<mvc:freemarker prefix="" suffix=".ftl"
|
||||
template-loader-paths="/,/test" cache="false" />
|
||||
|
||||
<mvc:velocity prefix="" suffix=".vm"
|
||||
resource-loader-path="/" cache="false" />
|
||||
|
||||
</mvc:view-resolution>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?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:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<mvc:view-resolvers>
|
||||
<mvc:jsp prefix="/WEB-INF/" suffix=".jsp" />
|
||||
<mvc:bean-name />
|
||||
<mvc:tiles definitions="/org/springframework/web/servlet/resource/tiles/tiles1.xml,/org/springframework/web/servlet/resource/tiles/tiles2.xml" />
|
||||
<mvc:freemarker prefix="" suffix=".ftl" templateLoaderPath="/" />
|
||||
</mvc:view-resolvers>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user