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 ...
随机推荐
- [JAVA · 0基础]:19.容器类
概述 容器 就是存放数据的一个集合 (java提供了一个接口专门去约束我们容器的实现类) watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L ...
- JSP -> f:loadBundle用法
jsp中出现<f:loadBundle basename="messages_zh_CN" var="msgs" /> 还有src目录下有messa ...
- c# 如何利用异或运算进行简单加密解密
利用“^”异或运算对字符串进行加密 原理:按位做“异或”运算是->位值相同得1,不同得0,如下计算 1 ^ 1 = 0 1 ^ 0 = 1 0 ^ 1 = 1 0 ^ 0 = 0 例如: < ...
- js引入方式的弹框方法2
html代码: <!DOCTYPE html> <html lang="zh-CN"> <head> <meta http-equiv=& ...
- java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x87<b
实际开发中遇到的 情景: 解决方案: 复制的别人的博客,没测试, Incorrect string value: '\xF0\x9F...' for column 'XXX' at row 1 这个 ...
- 2014-08-28——移动端web开发,基本Meta标签
1.<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scal ...
- offset,scroll,client系列
offsetHeight: 元素高,height+border+paddingoffsetWidth: 元素宽,width+border+paddingoffsetTop: 距离offsetParen ...
- PAT 1002. A+B for Polynomials (25)
This time, you are supposed to find A+B where A and B are two polynomials. Input Each input file con ...
- 给俺的 CSDN 博客加背景音乐 - 高大尚的《心经》背景音乐
给俺的 CSDN 博客加背景音乐 - 高大尚的<心经>背景音乐 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途- ...
- DOM 属性操作
1 属性节点 2 attribute操作 3 value获取值操作 4 class的操作 5 指定CSS操作 1.属性节点 //获取文本节点的值 var divEle = document.getEl ...