大佬教程收集整理的这篇文章主要介绍了fastJson设置接口只接受json格式数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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> @H_616_8@
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) {} } @H_616_8@
以上是大佬教程为你收集整理的fastJson设置接口只接受json格式数据全部内容,希望文章能够帮你解决fastJson设置接口只接受json格式数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。