Optional int parameter 'xx' is present but cannot be translated into a null value

2023-12-22 13:38

本文主要是介绍Optional int parameter 'xx' is present but cannot be translated into a null value,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

今天在controller中获取post参数时,报了如下错误

{ "timestamp": "2018-09-07T07:25:51.524+0000", "status": 500, "error": "Internal Server Error", "message": "Optional int parameter 'id' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.", "path": "/user/add" 
}

查看报错信息

Optional int parameter 'id' is present but cannot be translated into a null value

意思是id不能转换为空,后面也给出了修改的建议

Consider declaring it as object wrapper for the corresponding primitive type.

可以用包装类Integer来避免这个错误

在springmvc接受参数的时候,尽量不要使用基本数据类型

这篇关于Optional int parameter 'xx' is present but cannot be translated into a null value的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/524150

相关文章

mybatis和mybatis-plus设置值为null不起作用问题及解决

《mybatis和mybatis-plus设置值为null不起作用问题及解决》Mybatis-Plus的FieldStrategy主要用于控制新增、更新和查询时对空值的处理策略,通过配置不同的策略类型... 目录MyBATis-plusFieldStrategy作用FieldStrategy类型每种策略的作

ImportError: cannot import name ‘print_log‘ from ‘logging‘

mmcv升级到2.+后删除了很多 解决 查FAQ文档,找到 添加到mmcv.utils下即可

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef‘ of undefined“

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef’ of undefined” 最近用vue做的一个界面,引入了一个子组件,在父组件中调用子组件的方法时,报错提示: [Vue warn]: Error in v-on handler: “TypeError: Cannot read property ‘methods

JAVA 中的Optional类详解

JAVA 中的Optional类详解 一、引言 Java 8 引入了 Optional 类,旨在提供一种更优雅的方式来处理可能为 null 的情况,从而避免 NullPointerException。Optional 是一个容器对象,它可能包含也可能不包含非空值。使用 Optional 可以显著减少代码中的 null 检查,使代码更加简洁和安全。 二、Optional 类的基本概念 1、创

Unstructured cannot write mode RGBA as JPEG 错误解决

Unstructured cannot write mode RGBA as JPEG 错误解决 0. 错误详细1. 解决方法 0. 错误详细 Image Extraction Error: Skipping the failed imageTraceback (most recent call last):File "/root/miniconda3/envs/learn-y

Cannot read property ‘length‘ of null while opening vscode terminal

同一问题地址:Cannot read property ‘length’ of null while opening vscode terminal 问题描述 One day, 我在ubuntu 18.04下用vscode打开一个项目,并想和往常一样在vscode使用终端,发现报错Cannot read property 'length' of null。 解决 打开setting.jso

瑞芯微Parameter File Format解析

Rockchip android系统平台使用parameter文件来配置一些系统参数 主要包含:串口号:nandflash分区 固件版本,按键信息等; 如下是台电P98HD的parameter参数: FIRMWARE_VER:4.1.1        // 固件版本 //固件版本,打包 updata.img 时会使用到,升级工具会根据这个识别固件版本。 //Boot loader 会读取

非空约束(Not Null)

修改表添加非空约束 使用DDL语句添加非空约束 ALTER TABLE 表名 MODIFY 列名 类型 NOT NULL; 示例: 向emp表中的salary添加非空约束。 alter table emp modify salary float(8,2) not NULL; 删除非空约束 使用DDL语句删除非空约束 ALTER TABLE 表名 MODIFY 列名 类型 NULL;

The import com.google cannot be resolved

The import com.google cannot be resolved,报错: 第一感觉就是缺少jar包,因为项目用maven管理,所以在pom.xml中添加: <dependency>  <groupId>com.google.code.gson</groupId>  <artifactId>gson</artifactId>  <version>2.3.1</ver

nexus3.XX的下载安装和配置

nexus的下载: 官方地址:http://www.sonatype.com/download-oss-sonatype 百度网盘:http://pan.baidu.com/s/1eSBeid0 下载完成后,将nexus解压到指定位置:(如d:\nexus3) nexus的安装: 开始 -> 运行 -> cmd install  安装 uninstall 卸载 此