HTTP Status 415 - request entity is in a format not supported

后端 未结 5 1124
忘掉有多难
忘掉有多难 2021-02-07 03:24

I am working on java restful web service. I got it working for GET request, but POST request does not work. My Controller class is RestController. I have done these

5条回答
  •  余生分开走
    2021-02-07 03:43

    Spring provides out-of-box many default HttpMessageConverters, which will be used for conversion, depending on presence of certain library in project classpath.

    For example, if the Content-Type in request Header was one of application/json or application/xml , that means the POST body contains json or XML[Popular formats], and if Jackson library is found in your classpath, Spring will delegate the conversion to MappingJackson2HttpMessageConverter [for json] or MappingJackson2XmlHttpMessageConverter [for xml].

    To declare a dependency to Jackson library (jackson-databind) include following dependency in your pom.xml

    
        com.fasterxml.jackson.core
        jackson-databind
        ${jackson.version}
    
    

提交回复
热议问题