参考文章:https://www.cnblogs.com/gxz-sw/p/6860447.html?ivk_sa=1024320u

1.先得有这个alibaba的jar包

image.png

  1. <dependency>
  2. <groupId>com.alibaba</groupId>
  3. <artifactId>fastjson</artifactId>
  4. <version>1.2.66</version>
  5. </dependency>

2.springmvc配置

  1. <mvc:annotation-driven>
  2. <mvc:message-converters register-defaults="true">
  3. <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
  4. <bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
  5. <property name="supportedMediaTypes">
  6. <list>
  7. <value>application/json;charset=UTF-8</value>
  8. </list>
  9. </property>
  10. </bean>
  11. </mvc:message-converters>
  12. </mvc:annotation-driven>

3.正常使用

  1. @ResponseBody
  2. @RequestMapping("/addFaceData")
  3. public Result addFaceData(Customer a, String baseimg){

备注:这个配置很关键,如果不配置的话,会导致不进springmvc的control层