今天在操作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. xpath与css基本使用方法

    path使用方法 1.工具Firefox50版本以下,安装插件firebug.firepath

  2. CODEVS 必做题:3149、2821、1531、3369、1230

    3149 爱改名的小融 2  时间限制: 2 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description Wikioi上有个人叫小融,他喜 ...

  3. MVC action 执行两次 background url()

    大年初七第一天上班就来解决问题,我也是醉了. 其实是历史遗留问题,今天看到后不能忍了,赶紧解决一下. 旧系统中以一个微信版本的列表页面没有问题,在新系统中重新开发一边后发现列表页面的action总是请 ...

  4. 第五课 nodejs 路由实现并处理请求作出响应

    1创建一个http Server 文件server.js var http = require('http');var url = require('url');function start(rout ...

  5. ECMAScript/JS 基础知识讲解

    闭包 下面这个方法能输入0 1 2 ... 9吗?显然是不可以的,输出结果是10个10. function test() { var arr = []; for(var i = 0; i < 1 ...

  6. 新手之使用git

    本篇博客针对不会Git的小童鞋,大神们可以绕过,错误之处谢谢指正: 关于GitHub的强大此处不在说明,知道GitHub也有一段时间了,但是一直苦于不会使用. 本篇文章介绍的是如何将工程代码托管到上面 ...

  7. php自定义函数: 时间转换成智能形式

    function time_trans($paratime,$suffix=false){ $now_time = time(); $dur = $now_time - $paratime; $suf ...

  8. [转载]$(document).ready(function(){});

    转载自:http://www.cnblogs.com/king-sheng/archive/2012/01/06/2313980.html $(document).ready(function() 页 ...

  9. SQL SERVER临时表的使用

    SQL SERVER临时表的使用 drop table #Tmp   --删除临时表#Tmpcreate table #Tmp --创建临时表#Tmp(    ID   int IDENTITY (1 ...

  10. PopuWindow和软件盘共存时的设置

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/mingyue_1128/article/details/32316069 一.键盘不消失,popuw ...