Optional int parameter 'pId' is present but cannot be translated into a null value due to being declared as a primitive type.
接口测试的时候遇到了一个问题,导致测试阻断了好久,在此记录,谨防忘记。
具体报错如下:
Optional int parameter 'pId' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

接口测试代码如下:

出问题的就是这个pId,
百度了下这个问题的原因,归根结底就是参数类型错误了:
可选的参数 pId不存在,但无法被转换为NULL,是因为你把它给定义为 基本类型。建议将其修改为 包装类型。
就是说,你定义了参数:String pId,但没有值,那按理来说按照null来处理,结果倒霉的事情来了:pId= null; 是不允许的,因为基础类型不能赋值为null。
所以建议把参数定义修改为Inteter pId.
那为啥用Integer可以,用int不行呢,原因如下:
Integer 允许为null值,int默认0,数据库里面如果有个字段没有值可能默认值为null,所以用Integer。
在hashmap中只能用Integer而不能用int
int是基本数据类型,定义一个整型数据。Integer是一个类,在hashmap中代表一个对象,所以用object表示。
原文地址:https://www.jianshu.com/p/1153070468e1
Optional int parameter 'pId' is present but cannot be translated into a null value due to being declared as a primitive type.的更多相关文章
- Optional int parameter 'fundID' is present but cannot be translated into a null value due to being declared as a primitive type
错误的意思是: "可选的int参数'fundID'存在但由于被声明为基本类型而无法转换为空值" 意思是fundID被申明为int的基本数据类型, 不能转换为字符串的null值. 难 ...
- is present but cannot be translated into a null value due to being declared as a primitive type
解决办法:把基本类型改为对象,譬如此处将pageId的类型由int 改为Integer 2016-10-19 19:36:11.275 DEBUG [http-nio-9999-exec-2][org ...
- Optional int parameter 'time' is present but cannot be translated into a null value due to being decla
今天在操作redis的时候报了这个错:Optional int parameter 'time' is present but cannot be translated into a null val ...
- Optional int parameter 'rows' is not present but cannot be translated into a null value due to being declared as a primitive type.
我的spring mvc 代码: @Controller @RequestMapping("/product") public class Fancy { @RequestMapp ...
- Optional int parameter 'id' is present but cannot be translated into a null value due to being decla
这个错误可以将参数由int改为Integer
- Optional int parameter 'resourceState' is present but cannot be translated into a null value
错误日志: java.lang.IllegalStateException: Optional int parameter 'resourceState' is present but cannot ...
- Tomcat上java.lang.IllegalStateException: Optional int parameter 'id' is not present
今日, 本人在tomcat+spring mvc平台的服务器上遇到java.lang.IllegalStateException: Optional int parameter 'id' is not ...
- Required String parameter ' ' is not present
Required String parameter ' ' is not present 报错原因: url中的参数错误. 解决方法: 1.修正url中的参数的值. 2.在Controller层中的@ ...
- 使用springmvc报错Required int parameter 'age' is not present
仔细检查jsp代码 <a href="springmvc/testRequestParam?username=atguigu$age=11">Test RequestP ...
随机推荐
- webpack打包配置中出现的问题
第一个错误: One CLI for webpack must be installed. These are recommended choices, delivered as separate p ...
- 【记录】git 拉取远程分支代码,同步到另一个git上
最近有需求从某git 上拉取所有分支代码同步到另一git上,现记录操作步骤,以便日后使用: 1:先克隆其中一个分支代码到本地环境 git clone -b test http://账号:密码@XXX. ...
- ARM与X86 CPU架构区别
CISC(复杂指令集计算机)和RISC(精简指令集计算机)是当前CPU的两种架构.它们的区别在于不同的CPU设计理念和方法.早期的CPU全部是CISC架构,它的设计目的是 CISC要用最少的机器语言指 ...
- c++后台开发面试常见知识点总结(六)算法手写
链表倒转 leetcode-206 连续子数组最大和问题(和最大的连续子序列的和) leetcode-53 输出字符串中最长的回文子串长度? leetcode-5 一个字符串,求最长无重复子串 ...
- 【leetcode】999. Available Captures for Rook
题目如下: On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bisho ...
- C/C++ C++ 11 std::bind()
{ #define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA ...
- Qt事件学习
一.创建Qt gui应用对应的源码: 点击(此处)折叠或打开 //mylineedit.h #ifndef MYLINEEDIT_H #define MYLINEEDIT_H #include < ...
- vue基础九
1.使用组件 1.1注册 要注册一个全局组件,你可以使用 Vue.component(tagName, options). 例如: Vue.component('my-component', { // ...
- 数据库的显示、创建、使用 、用户授权管理及忘记root用户后重置密码
1.显示数据库 show databases; 默认的数据库及大致功能: mysql -- 用户权限 相关数据 test --用于用户测试数据 information_schema -MySQL 本身 ...
- LiveTelecast直播平台技术图谱skill-map
#直播平台技术图谱 ----##直播 ----###采集- **iOS** * HTTP Live Streaming * DirectShow- **Android** * setPreviewCa ...