今天在操作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的更多相关文章

  1. Optional int parameter 'id' is present but cannot be translated into a null value due to being decla

    这个错误可以将参数由int改为Integer

  2. 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 ...

  3. 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值. 难 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Tomcat上java.lang.IllegalStateException: Optional int parameter 'id' is not present

    今日, 本人在tomcat+spring mvc平台的服务器上遇到java.lang.IllegalStateException: Optional int parameter 'id' is not ...

  8. Required String parameter ' ' is not present

    Required String parameter ' ' is not present 报错原因: url中的参数错误. 解决方法: 1.修正url中的参数的值. 2.在Controller层中的@ ...

  9. 使用springmvc报错Required int parameter 'age' is not present

    仔细检查jsp代码 <a href="springmvc/testRequestParam?username=atguigu$age=11">Test RequestP ...

随机推荐

  1. ios -生成推广海报

    #import "ViewController.h" #import "Masonry.h" @interface ViewController () @end ...

  2. 现代 PHP 新特性系列

    生成器的创建和使用 http://laravelacademy.org/post/4317.html

  3. nginx配置后只有根目录首页index.php能访问,其他页面404

    只有首页面根目录可以访问,其他页面地址都是404 not found.网上找了半天url重定向,url重写都试了无效,要不就是重定向过多,下图为跳坑历程. location / { #if ($htt ...

  4. Git安装部署

    1.1 最新git源码下载地址 https://github.com/git/git/releases https://www.kernel.org/pub/software/scm/git/ 1.2 ...

  5. PHP 可以获取客户端哪些访问信息

    php是一种弱类型的程序语言,但是最web的 在程序语言中有系统全局函数: $_SERVER <?php echo "".$_SERVER['PHP_SELF'];#当前正在 ...

  6. 《从零开始学Swift》学习笔记(Day 26)——可选链

    原创文章,欢迎转载.转载请注明:关东升的博客 在Swift程序表达式中会看到问号(?)和感叹号(!),它们代表什么含义呢?这些符号都与可选类型和可选链相关,下面来看看可选链. 可选链: 类图: 它们之 ...

  7. Balala Power!(大数+思维)

    Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  8. Introduction to Mathematical Thinking - Week 4

    否定的逻辑 应该思考符号背后表示的逻辑,而不是像操作算术运算符一样操作逻辑符号. 比如 对于任意的 x,x属于自然数,那么 x 是偶数或者奇数:这是对的 如果使用“乘法分配律”拆分,变成“对于任意的x ...

  9. recursion

    w recursion nexttoken

  10. JavaWeb 之文件下载

    1. 下载概述 下载就是向客户端响应字节数据! 将一个文件变成字节数组, 使用 response.getOutputStream() 来响应给浏览器!! 2. 下载要求 两个头一个流 Content- ...