一、URL:接口URL1
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
第一个问题很大慨率就是接口URL1 需要通过 AFNetworking 表单的形式提交数据
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
二、URL:接口URL2
org.springframework.web.bind.MissingServletRequestParameterException: Required Long parameter '参数' is not present
很大的概率就是参数传空字符串 解决思路就是针对参数从不同页面之间传递添加一些硬编码
同时对参数字符串做判空的操作,字符串合法才会进入下一个页面。
三、NullPointerException就是传参数为null


参考文章:
https://www.huaweicloud.com/articles/94628f92a7d124ee1ba77e8b55ab90b9.html
接口异常处理与参数校验
本文探讨了两个常见的接口调用问题:1) 接口URL1在使用AFNetworking时遇到Content-Type不被支持的问题,可能需要调整请求和响应序列化器;2) 接口URL2的参数缺失导致MissingServletRequestParameterException,解决方案是确保参数在页面间传递时不为空,并进行空值检查。通过这些方法可以优化接口交互和参数验证。
2088

被折叠的 条评论
为什么被折叠?



