Content Negotiation Strategy
This commit is contained in:
parent
aea2aafe06
commit
800285f30c
|
@ -98,6 +98,18 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Json conversion -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>2.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -2,7 +2,9 @@ package com.baeldung.spring.form;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
public class Employee {
|
public class Employee {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?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:context="http://www.springframework.org/schema/context"
|
||||||
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context-4.2.xsd
|
||||||
|
http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
|
||||||
|
|
||||||
|
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
|
||||||
|
<context:component-scan base-package="org.baeldung.spring.controller" />
|
||||||
|
<bean id="viewResolver"
|
||||||
|
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||||
|
<property name="prefix" value="/WEB-INF/view/" />
|
||||||
|
<property name="suffix" value=".jsp" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<mvc:view-controller path="/sample.html" view-name="sample" />
|
||||||
|
|
||||||
|
<!-- Content strategy using path extension -->
|
||||||
|
<bean id="contentNegotiationManager"
|
||||||
|
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||||
|
<property name="favorPathExtension" value="true" />
|
||||||
|
<property name="favorParameter" value="false"/>
|
||||||
|
<property name="parameterName" value="mediaType"/>
|
||||||
|
<property name="ignoreAcceptHeader" value="true" />
|
||||||
|
<property name="defaultContentType" value="text/html" />
|
||||||
|
<property name="useJaf" value="false" />
|
||||||
|
|
||||||
|
<property name="mediaTypes">
|
||||||
|
<map>
|
||||||
|
<entry key="html" value="text/html" />
|
||||||
|
<entry key="json" value="application/json" />
|
||||||
|
<entry key="xml" value="application/xml" />
|
||||||
|
</map>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
</beans>
|
Loading…
Reference in New Issue