分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

fastJson设置接口只接受json格式数据

发布时间:2023-09-06 02:26责任编辑:赖小花关键词:jsjson

spring-mvc/servlet.xml

<mvc:annotation-driven> ???????<mvc:message-converters register-defaults="true"> ???????????<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> ???????????????<property name="features"> ???????????????????<list> ???????????????????????<value>WriteMapNullValue</value> ???????????????????????<value>QuoteFieldNames</value> ???????????????????????<value>WriteDateUseDateFormat</value> ???????????????????????<!-- 禁用fastjson循环引用检测 --> ???????????????????????<value>DisableCircularReferenceDetect</value> ???????????????????</list> ???????????????</property> ???????????</bean> ???????</mvc:message-converters> ???</mvc:annotation-driven>

  

controller:

@RestController@RequestMapping("/api/flights")public class ApiFlightsController { ???@Autowired ???private RedisService redisService; ???/** ????* 查询 ????* @param flightSearchForm ????* @param bindingResult ????* @return ????*/ ???@RequestMapping(value = "/search", method = RequestMethod.POST, ?produces = {"application/json;charset=UTF-8"}) ???public ResultUtil search(@Valid @RequestBody FlightSearchForm flightSearchForm, BindingResult bindingResult) ???{}}

  

fastJson设置接口只接受json格式数据

原文地址:https://www.cnblogs.com/achengmu/p/10110516.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved