Announcement Announcement Module
No announcement yet.
HttpMediaTypeNotSupportedException-Content type 'application/x-www-form-urlencoded' n Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpMediaTypeNotSupportedException-Content type 'application/x-www-form-urlencoded' n

    Hi all,

    I am trying to create a Spring REST service using @RequestBody to translate XML data to my mapped objects.

    I am doing a POST to 'create' but the 'create' method was never triggered. The debugger shows:

    HttpMediaTypeNotSupportedException, id=192
    MediaType id=197
    Content type 'application/x-www-form-urlencoded' not supported

    My POJO for mapping the XML data:

    public class XMLObject {

    My Controller:

    public class XMLObjectController {
    @RequestMapping(value = "/xmlobject", method = RequestMethod.POST)
    public String create(@RequestBody XMLObject xmlobject, ModelMap modelMap) {
    System.out.println("XMLObject: " + xmlobject);
    if (xmlobject == null) throw new IllegalArgumentException("An XMLObject request is required");
    return "redirect:/xmlobject/";

    My webmvc_config.xml:

    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
    <property name="classesToBeBound">
    <!-- <property name="schema" value="classpath:org/springframework/oxm/schema.xsd"/> -->

    <bean class="org.springframework.web.servlet.mvc.annotat ion.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
    <ref bean="marshallingHttpMessageConverter"/>

    <bean id="marshallingHttpMessageConverter"
    class="org.springframework.http.converter.xml.Mars hallingHttpMessageConverter">
    <property name="marshaller" ref="marshaller" />
    <property name="unmarshaller" ref="marshaller" />

    Any ideas will be greatly appreciated.

    Many Thanks in advance.