java.lang.IllegalStateException: Optional int parameter 'studentid' is present but cannot be transla
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, 一样也是不行的。
@RequestParam注解的使用
RequestParam来映射请求参数
required表示是否
java.lang.IllegalStateException: Optional int parameter 'studentid' is present but cannot be transla相关推荐
- java.lang.IllegalStateException: Optional int parameter 'ww_id' is present but cannot be translated
这个错误我百度首先找到了一个![在这里插入图片描述](https://img-blog.csdnimg.cn/20190603195425696.png?x-oss-process=image/wat ...
- java.lang.IllegalStateException: Optional long parameter 'adminId' is present but cannot be translat
把 long 换成 Long 转载于:https://my.oschina.net/LinuxDaxingxing/blog/917158
- Optional int parameter ‘xxx‘ is present but cannot be translated into a null value due to being decl
错误描述: processing failed; nested exception is java.lang.IllegalStateException: Optional int parameter ...
- Optional int parameter 'page' is present but cannot be translated into a null value due to being dec
这个错误犯两回了 int改integer 原始类型不能为null 包装类可以 我的spring mvc 代码: @Controller @RequestMapping("/product&q ...
- Optional int parameter xxx is present but cannot be translat
java.lang.IllegalStateException: Optional int parameter 'pageCode' is present but cannot be translat ...
- Optional int parameter ‘xxx‘ is present but cannot be translated into a null value due to being.....
异常代码 `j`ava.lang.IllegalStateException: Optional int parameter 'tyId' is present but cannot be trans ...
- Optional int parameter 'id' is present but cannot be translated into a null value due to being
执行## ........(int id);报出以下错误. Optional int parameter 'id' is present but cannot be translated into a ...
- Optional int parameter ‘page‘ is present but cannot be translated into a null value due to being dec
背景:在测试上面这个controller时(status为查询条件Limit,查询status为1/0的所有记录),当用postman发出请求http://localhost:8080/orders/ ...
- Optional int parameter ‘id‘ is present but cannot be translated into a null value
接收参数时遇到的问题 开始的代码 @RequestMapping("/deleteComment")@ResponseBodypublic ResultInfo deleteCom ...
最新文章
- 再读《数量生态学:R语言应用》
- 【rnnoise源码分析】compute_frame_feature函数
- LeetCode总结 -- 树的遍历篇
- How your face shapes your economic chances
- Java自带的多线程监控分析工具(VisualVM)
- 报名 | 网易MCtalk: 5G+AI新时代 探索音视频技术创新与实践
- 你已经用上 5G 网络了吗?
- Azure 内容审查器之羞羞图审查
- 利用Mybatis对数据库进行增删改查操作
- CGI(通用网关接口)
- round()四舍五入方法的简单使用
- smartadmin_smartadmin官网_smartadmin下载 bootstrap 后台模板 下载-很不错的后台模板
- OpenCV图像处理----图像的二值化
- scratch节假日课程:春节舞狮
- 基于存储卡的音乐播放器0.6
- mkv转mp4,mkv转换mp4格式
- 王者荣耀登录显示换服务器是不是封号,王者荣耀这么查看封号原因?千万不要这么做!...
- linux清理dns缓存命令,Ubuntu下清空DNS缓存 提升访问速度
- Python自学之路第十四步——与周杰伦有关的岁月
- .md文件是什么?.md如何打开?怎么打开?