• 问题:使用SpringMVC框架后,接口中入参对象没使用@RequestBody注解,造成postman发起post请求,from-data格式请求可以调通接口,但是raw格式请求调不通接口,然后我加了SpringMVC @ResponseBody 注解,调接口显示415错误。
  • 处理:
    • SpringMVC添加配置、注解:
 1  <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
 2         <property name="messageConverters">
 3             <list>
 4                 <ref bean="jsonHttpMessageConverter" />
 5             </list>
 6         </property>
 7    </bean>
 8  
 9    <bean >
10         <property name="supportedMediaTypes">
11             <list>
12                 <value>application/json;charset=UTF-8</value>
13             </list>
14         </property>
15    </bean>
View Code

相关文章: