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 value due to being decla
这句话意思:参数time存在,但是无法将其转为为null
查看了下原因,time这个字段是用来记录设置多久时间过期的,
我在service层设置的是Long 类型, 我在Controller 层设置的是long类型,前后设置的不一样,猜测前后需要设置一致,
于是我就将Contoller 设置为了Long类型,于是就通过了。
但是我在接受前台传送过来的参数时,使用Long接收, 在Service层使用long 同样没有报错。
之后我更改为前后都使用long,然后就报错了。
想了下springmvc在接受参数的时候,如果不存在,那么会将这个值设置为null,如果你用基本数据类型,
那么怎么给其赋值为空呢?
总结:大家以后在springmvc接受参数的时候,尽量不要使用基本数据类型,当然你一定要使用的话,可以把defaultValue加上,这样就不会报这个错误了。
注意:就算你加上required=false, 一样也是不行的。
Optional int parameter 'time' is present but cannot be translated into a null value due to being decla的更多相关文章
- Optional int parameter 'id' is present but cannot be translated into a null value due to being decla
这个错误可以将参数由int改为Integer
- 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 tr ...
- 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值. 难 ...
- 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 ...
- 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 '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 ...
- 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 ...
随机推荐
- php读取xml的神器
<?xml version="1.0 encoding="UTF-8"?> <humans> <zhangying> <name ...
- IOS 关于取消延迟执行函数的种种。performSelector与cancelPreviousPerformRequestsWithTarget
本文非本人撰写 @interface NSObject (NSDelayedPerforming) - (void)performSelector:(SEL)aSelector withObj ...
- activity通过流程实例id动态获取流程图并展示在jsp页面上
提供的Service方法如下: Java /** * 获取当前任务流程图 * * @param processInstanceId * @return */ @Override public Inpu ...
- ES6学习笔记之变量声明let,const
最近用淘宝的weex做了个项目,最近稍微闲下来了.正好很久没有接触RN了,所以趁这个机会系统的学习一下ES6的相关知识. 孔子说:没有对比就没有伤害.所以我们要拿ES6和ES5好好对比的学习.这样才能 ...
- 次小生成树模板(poj1679)
prim #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath&g ...
- a标签里面包含img标签,出现a标签的高度高于img标签好几个px
问题:a标签里面包含img标签,出现a标签的高度高于img标签好几个px 解决: a元素下有一个匿名文本,这个文本外有一个匿名行级盒子,它有的默认vertical-align是baseline的,而且 ...
- Nuxt使用高德地图
事先准备 注册账号并申请Key 1. 首先,注册开发者账号,成为高德开放平台开发者 2. 登陆之后,在进入「应用管理」 页面「创建新应用」 3. 为应用添加 Key,「服务平台」一项请选择「 Web ...
- Django 进阶(分页器&中间件)
分页 Django的分页器(paginator) view from django.shortcuts import render,HttpResponse # Create your views h ...
- Python2 和 Python3 区别汇总
[Python2 和 Python3 的区别汇总,不定期补充] print 在进行程序调试时用得最多的语句可能就是 print,在 Python 2 中,print 是一条语句,而 Python3 中 ...
- python模块学习(一)
模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需要多个函数才 ...