mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:35:49 +00:00
fixed content negotiation configuration
This commit is contained in:
parent
bfa4f85a83
commit
05c1110dce
1 changed files with 38 additions and 23 deletions
|
@ -17,7 +17,6 @@
|
|||
|
||||
|
||||
<mvc:annotation-driven />
|
||||
<!-- <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" /> -->
|
||||
|
||||
<!-- all resources inside folder src/main/webapp/resources are mapped so they can be refered to inside JSP files
|
||||
(see header.jsp for more details) -->
|
||||
|
@ -27,6 +26,38 @@
|
|||
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
||||
|
||||
|
||||
<!--
|
||||
- This view resolver delegates to the InternalResourceViewResolver and BeanNameViewResolver,
|
||||
- and uses the requested media type to pick a matching view. When the media type is 'text/html',
|
||||
- it will delegate to the InternalResourceViewResolver's JstlView, otherwise to the
|
||||
- BeanNameViewResolver. Note the use of the expression language to refer to the contentType
|
||||
- property of the vets view bean, setting it to 'application/vnd.springsource.samples.petclinic+xml'.
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
|
||||
<property name="contentNegotiationManager">
|
||||
<bean class="org.springframework.web.accept.ContentNegotiationManager">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry key="xml" value="#{vets.contentType}"/>
|
||||
<entry key="atom" value="#{visits.contentType}"/>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="order" value="0"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
- The BeanNameViewResolver is used to pick up the visits view name (below).
|
||||
- It has the order property set to 2, which means that this will
|
||||
- be the first view resolver to be used after the delegating content
|
||||
- negotiating view resolver.
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="1"/>
|
||||
<!--
|
||||
|
||||
- This bean configures the 'prefix' and 'suffix' properties of
|
||||
|
@ -35,7 +66,7 @@
|
|||
- will be mapped to "/WEB-INF/jsp/vets.jsp".
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
|
||||
p:suffix=".jsp" />
|
||||
p:suffix=".jsp" p:order="2"/>
|
||||
|
||||
<!--
|
||||
- Message source for this context, loaded from localized "messages_xx" files.
|
||||
|
@ -82,31 +113,15 @@
|
|||
|
||||
|
||||
|
||||
<!-- <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||
<property name="favorPathExtension" value="false" />
|
||||
<property name="favorParameter" value="true" />
|
||||
<property name="mediaTypes">
|
||||
<value>
|
||||
atom=application/atom+xml
|
||||
html=text/html
|
||||
xml=application/xml
|
||||
</value>
|
||||
</property>
|
||||
</bean> -->
|
||||
|
||||
|
||||
<!--
|
||||
- The BeanNameViewResolver is used to pick up the visits view name (below).
|
||||
- It has the order property set to 1, which means that this will
|
||||
- be the first view resolver to be used after the delegating content
|
||||
- negotiating view resolver.
|
||||
-->
|
||||
<!-- <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- - The AtomView rendering a Atom feed of the visits -->
|
||||
|
||||
<!-- <bean id="visits" class="org.springframework.samples.petclinic.web.VisitsAtomView"/>
|
||||
<bean id="visits" class="org.springframework.samples.petclinic.web.VisitsAtomView"/>
|
||||
|
||||
<bean id="vets" class="org.springframework.web.servlet.view.xml.MarshallingView">
|
||||
<property name="contentType" value="application/vnd.springsource.samples.petclinic+xml"/>
|
||||
|
@ -115,7 +130,7 @@
|
|||
|
||||
<oxm:jaxb2-marshaller id="marshaller">
|
||||
<oxm:class-to-be-bound name="org.springframework.samples.petclinic.Vets"/>
|
||||
</oxm:jaxb2-marshaller> -->
|
||||
</oxm:jaxb2-marshaller>
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue