415 Unsupported Media Type

Рейтинг: 1Ответов: 0Опубликовано: 04.11.2014

Пытаюсь сделать простейший POST запрос к spring mvc... получаю ответ "415 Unsupported Media Type".

Помогите, пожалуйста, разобраться или подскажите, где почитать.

dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <mvc:annotation-driven />
    <context:component-scan base-package= "com.test"/>

</beans>

IndexController.java

@RequestMapping(value = "/",  method = RequestMethod.POST)
@ResponseBody
public int index(@RequestBody Test request){
    return request.getId();
}

Test.java

int id;

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

Ответы

Ответов пока нет.