解决——》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 ...
随机推荐
- 企业级Nginx负载均衡与keepalived高可用实战(二)keepalived篇
1.Keepalived高可用软件 1.1.Keepalived介绍 Keepalived软件起初是专门为LVS负载均衡软件设计的,用来管理并监控LVS集群系统中各个服务节点的状态,后来又加入了可以实 ...
- 【08月02日】A股滚动市盈率PE历史新低排名
2010年01月01日 到 2019年08月02日 之间,滚动市盈率历史新低排名. 上市三年以上的公司,2019年08月02日市盈率在300以下的公司. 1 - XD栖霞建(SH600533) - 历 ...
- BizTalk增强型RosettaNet跟踪报告
BizTalk 的数据报表能力一直是比较弱的,好在Rosettanet 支持使用BAM 跟踪功能来跟踪各PIP消息状态.增强的跟踪功能能跟踪流程为消息.错误和事件.不可否认性的数据.可以根据跟踪的 ...
- jquery easyui datagrid 加载保存好的自定义设置的列属性
直接附上源代码 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...
- HTTP之如何控制缓存
HTTP控制缓存的能力 ===================摘自<HTTP权威指南>==================================== 服务器可以通过HTTP定义的 ...
- Python 发送企业微信消息
1.获取企业微信信息 1)我的企业 --> 企业信息 --> 企业ID 2)创建一个应用,记录该应用的 AgentId.Secret 2.python代码 #!/usr/bin/env p ...
- C#快速入门指南
C# C#集成开发环境结构结构体枚举接口派生类全析 集成开发环境 Visual Studio 结构 using System; 包含 System 命名空间 class hello{ /*注释*/ s ...
- Spring Security简介与入门Demo
1:Spring Security简介 Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中配 ...
- Luogu P2727 【01串 Stringsobits】
看到题解里好像都是用$DP$解决的,本着禁止DP的原则,我来提供一发纯数学其实和DP本质相同的题解,前两天刚反演题,脑子炸了,本来说换换脑子,结果还是数学 首先受进制思想启发,我们不妨按位考虑,考虑这 ...
- sql server锁表、查询被锁表、解锁被锁表的相关语句
MSSQL(SQL Server)在我的印象中很容易锁表,大致原因就是你在一个窗口中执行的DML语句没有提交,然后又打开了一个窗口对相同的表进行CRUD操作,这样就会导致锁表.锁表是一种保持数据一致性 ...