mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-16 12:55:50 +00:00
Simplified ContentNegoViewResolver config
- Now using namespace, much simpler (11 lines instead of 27) - Just a minor issue with: <bean class="org.springframework.web.servlet.view.JstlView"> <property name="url" value="" /> </bean> (should investigate later if we can remove “url” attribute
This commit is contained in:
parent
8929d373ec
commit
92e7ab43be
1 changed files with 18 additions and 38 deletions
|
@ -2,51 +2,31 @@
|
||||||
<!--
|
<!--
|
||||||
- DispatcherServlet application context for PetClinic's web tier.
|
- DispatcherServlet application context for PetClinic's web tier.
|
||||||
-->
|
-->
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
xmlns:oxm="http://www.springframework.org/schema/oxm"
|
xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/oxm
|
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
|
||||||
http://www.springframework.org/schema/oxm/spring-oxm.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
|
||||||
<!--
|
<!--
|
||||||
- The ContentNegotiatingViewResolver delegates to the InternalResourceViewResolver and BeanNameViewResolver,
|
- The ContentNegotiatingViewResolver delegates to the InternalResourceViewResolver and BeanNameViewResolver,
|
||||||
- and uses the requested media type (determined by the path extension) to pick a matching view.
|
- and uses the requested media type (determined by the path extension) to pick a matching view.
|
||||||
- When the media type is 'text/html', it will delegate to the InternalResourceViewResolver's JstlView,
|
- When the media type is 'text/html', it will delegate to the InternalResourceViewResolver's JstlView,
|
||||||
- otherwise to the BeanNameViewResolver.
|
- otherwise to the BeanNameViewResolver.
|
||||||
-->
|
-->
|
||||||
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
|
<mvc:view-resolvers>
|
||||||
<property name="contentNegotiationManager" ref="cnManager"/>
|
<mvc:content-negotiation use-not-acceptable="true">
|
||||||
|
<mvc:default-views>
|
||||||
|
<bean class="org.springframework.web.servlet.view.JstlView">
|
||||||
|
<property name="url" value="" />
|
||||||
|
</bean>
|
||||||
|
</mvc:default-views>
|
||||||
|
</mvc:content-negotiation>
|
||||||
|
|
||||||
<property name="viewResolvers">
|
<!-- Registering BeanNameViewResolver and InternalViewResolver -->
|
||||||
<list>
|
<mvc:bean-name />
|
||||||
<!-- Default viewClass: JSTL view (JSP with html output) -->
|
<mvc:jsp prefix="/WEB-INF/jsp/" suffix=".jsp"/>
|
||||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
</mvc:view-resolvers>
|
||||||
<!-- Example: a logical view name of 'vets' is mapped to '/WEB-INF/jsp/vets.jsp' -->
|
|
||||||
<property name="prefix" value="/WEB-INF/jsp/"/>
|
|
||||||
<property name="suffix" value=".jsp"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Used here for 'xml' and 'atom' views -->
|
|
||||||
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Simple strategy: only path extension is taken into account -->
|
|
||||||
<bean id="cnManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
|
||||||
<property name="favorPathExtension" value="true"/>
|
|
||||||
<property name="ignoreAcceptHeader" value="true"/>
|
|
||||||
<property name="defaultContentType" value="text/html"/>
|
|
||||||
|
|
||||||
<property name="mediaTypes">
|
|
||||||
<map>
|
|
||||||
<entry key="html" value="text/html" />
|
|
||||||
<entry key="xml" value="application/xml" />
|
|
||||||
<entry key="atom" value="application/atom+xml" />
|
|
||||||
</map>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Renders an Atom feed of the visits. Used by the BeanNameViewResolver -->
|
<!-- Renders an Atom feed of the visits. Used by the BeanNameViewResolver -->
|
||||||
<bean id="vets/vetList.atom" class="org.springframework.samples.petclinic.web.VetsAtomView"/>
|
<bean id="vets/vetList.atom" class="org.springframework.samples.petclinic.web.VetsAtomView"/>
|
||||||
|
|
Loading…
Reference in a new issue