解决——》java.lang.IllegalArgumentException: Body parameter 0 was null
1、操作
2、现象(错误信息)
3、原因
错误代码:
4、解决
1)方案一:@RequestBody(required=false)
2)方案二:传参数时限制authSession不能为空
ody parameter 0 was null)
1、操作
调用controller时
2、现象(错误信息)
java.lang.IllegalArgumentException: Body parameter 0 was null
3、原因
SpringMVC方法中的@requestbody注解接收数据时,当参数为null时就报这个错""
错误代码:
@PostMapping(value = "/getCommunitiyFenceList")
public List<CommunityFenceRes> getCommunitiyFenceList(@RequestBody SearchCommunity search){
//其它代码
}
4、解决
@RequestBody的required默认值是true,也就是说参数不能为null
1)方案一:@RequestBody(required=false)
@PostMapping(value = "/getCommunitiyFenceList")
public List<CommunityFenceRes> getCommunitiyFenceList(@RequestBody(required=false) SearchCommunity search){
//其它代码
}
2)方案二:传参数时限制authSession不能为空
————————————————
版权声明:本文为CSDN博主「小仙。」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43453386/article/details/88913809
Feign场景,则必须new一个值
java.lang.IllegalArgumentException: Body parameter 0 was null
at feign.Util.checkArgument(Util.java:102) ~[feign-core-9.4.0.jar:na]
at feign.ReflectiveFeign$BuildEncodedTemplateFromArgs.resolve(ReflectiveFeign.java:348) ~[feign-core-9.4.0.jar:na]
at feign.ReflectiveFeign$BuildTemplateByResolvingArgs.create(ReflectiveFeign.java:213) ~[feign-core-9.4.0.jar:na]
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:72) ~[feign-core-9.4.0.jar:na]
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103) ~[feign-core-9.4.0.jar:na]
at com.sun.proxy.$Proxy77.umpDetails(Unknown Source) ~[na:na]
at com.omsserver.external.OmsAndUmpExternalService.findOmsAndUmpInfo(OmsAndUmpExternalService.java:31) ~[classes/:na]
at com.omsserver.controller.OmsController.selectUmpAndOmsInfo(OmsController.java:42) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5
解决——》java.lang.IllegalArgumentException: Body parameter 0 was null的更多相关文章
- 解决:“java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut myMethod”问题!
Spring版本:2.5.6 AspectJ是Spring自带的lib. Jdk版本:1.7.0_17 在配置没问题的情况下,报:java.lang.IllegalArgumentException: ...
- Java连接MongoDB报错“java.lang.IllegalArgumentException: clusterListener can not be null”的解决办法
我使用的MongoDB版本是3.6.9. 下面是一个很基础的示例代码,功能就是连接MongoDB: package com.zifeiy.snowflake.handle.etl.mongodb; i ...
- java.lang.IllegalArgumentException: clusterListener can not be null
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb. ...
- 严重: End event threw exception java.lang.IllegalArgumentException: Can't convert argument: null
堆栈信息: 2014-6-17 10:33:58 org.apache.tomcat.util.digester.Digester endElement 严重: End event threw exc ...
- eclipse maven构建的java web工程项目 在修改了工程项目名时,tomcat启动异常java.lang.IllegalArgumentException: Can't convert argument:null
问题 我修改了前一个项目的名称.重新启动该项目至tomcat,报错:Java.lang.IllegalArgumentException: Can't convert argument: null 因 ...
- tomcat解决 java.lang.IllegalArgumentException: Request header is too large
tomcat运行项目时,有一个请求过去后,后台报这样的错java.lang.IllegalArgumentException: Request header is too large 原因:请求头超过 ...
- 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList的问题
一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...
- 解决java.lang.IllegalArgumentException: No converter found for return value of type 的问题
controller返回一个dto,并且定义了@ResponseBody注解,表示希望将这个dto对象转换为json字符串返回给前端,但是运行时报错:nested exception is java. ...
- 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList问题
在spring + springmvc + mybatis框架中,我们配置接口对外返回json格式,但是报如下错误: 24-Oct-2017 17:42:23.495 严重 [http-nio-808 ...
随机推荐
- Win10 1903 运行安卓模拟器蓝屏解决方案
由于没有安卓机,想要测试一些东西,所以选择了安卓模拟器,可是一运行模拟器就导致电脑蓝屏,试了 N 次都不行. 于是在网上寻找解决方案,了解到导致蓝屏的原因都是因为虚拟化技术,我的系统是 Windows ...
- 用SQL语句去掉重复的记录
删除手机(mobilePhone),电话(officePhone),邮件(email)同时都相同的数据 1.delete from 表 where id not in (select max(id) ...
- golang strings常用函数
package main import ( "fmt" "strings" ) func main() { s1 := " aBc" s2 ...
- Springboot启动一直卡在{dataSource-1} inited
Springboot启动一直卡在{dataSource-1} inited 错误原因: 暂时未知,猜测是因为设置端点的问题 解决办法: 去除所有断点: 然后再次启动就好了. 如果还有错: 那么重新导入 ...
- MySQL8的密码策略
解释: 由于valiadte_password策略.密码强度需要非常高,所以有时候密码都无法成功修改.了解完下面变量就能解决了. validate_password.policy:密码策略,检查用户的 ...
- luogu P3853 [TJOI2007]路标设置 |二分
题目背景 B市和T市之间有一条长长的高速公路,这条公路的某些地方设有路标,但是大家都感觉路标设得太少了,相邻两个路标之间往往隔着相当长的一段距离.为了便于研究这个问题,我们把公路上相邻路标的最大距离定 ...
- 集合类源码(七)Map(ConcurrentHashMap, ConcurrentSkipListMap, TreeMap)
ConcurrentHashMap 内部结构 在JDK1.8之前的实现结构是:ReentrantLock+Segment+HashEntry+链表 JDK1.8之后的实现结构是:synchronize ...
- [转帖]银河麒麟Kydroid 2.0全新发布:原生支持海量安卓APP
银河麒麟Kydroid 2.0全新发布:原生支持海量安卓APP https://news.cnblogs.com/n/652299/将手机操作系统 转移到 桌面 跟chromebook 类似的策略吧 ...
- java 获取真实ip地址
/** * 获取真实ip地址 * @param request * @return */ public static String getIpAddress(HttpServletRequest re ...
- 新一代ActiveMQ —— Apache ActiveMQ Artemis
资料: .net demo : https://github.com/apache/activemq-artemis/tree/master/examples/protocols/amqp/dotne ...