Spring REST Form Data PUT method

2019-09-02 16:37发布

问题:

I have given below my spring controller and .xml file congif info .

class TestingController
{

    @RequestMapping(value="/addinfo",method=RequestMethod.PUT)
    public void addInfo(@RequestBody Userinfo user){
}

context

<mvc:annotation-driven/>
<bean id="contentNegotiationManager" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="ignoreAcceptHeader" value="true"/>
<property name="mediaTypes">
    <map>
        <entry key="json" value="application/json" />
        <entry key="xml" value="application/xml" />
    </map>
 </property>

This is working fine as i am expecting for the JSON and XML Request using REST Client. for example : {"user":"test","cval":"12","mval":"12} JSON working fine .

when i try to pass the data like user=test&cval=12&mval=12 using in request body using REST client with header "Content-Type:application/x-www-form-urlencoded" I am getting 415 error message.

My Requirement is SPring RESTfull Webservice need to handle the below Content-Type

1.application/json 2.application/xml 3.application/x-www-form-urlencoded

Regards Vasanth D