今天在新启动一个项目的时候,爆出了之前没有见过的异常
org.springframeework.wdb.HttpMeediaTypeeNotSupportEdException: Content-type:‘application/json;charset=UTF-8’ can not supported
在网上找了很多方式都不对,仔细思考了下,缺少json jar包和映射的支持
- pom.xml 加入json支持
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
- spring-mvc 添加映射
<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value> text/html; charset=UTF-8</value>
<value> application/json; charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>