我的spring mvc 代码:

@Controller
@RequestMapping("/product")
public class Fancy {
@RequestMapping(value = "/fancy")
@ResponseBody
public String showFancy(@RequestParam(value = "page", required = false) int page) {
return "{\"status\":\"ok\"+}"+page+"\t";
}
}

报错:

 Optional int parameter 'rows' is not 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.

大意是说 如果参数是非必须的,则会赋值为null,因此参数应该是一个object,它才能接受这个null值。

而上面代码参数page 的类型 为 int,它接受不了null值。

解决方法:

将int 改为 对象类型 Integer :

@RequestParam(value = "page", required = false) Integer page  

问题解决!end.

Optional int parameter 'rows' is not present but cannot be translated into a null value due to being declared as a primitive type.的更多相关文章

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

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

  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. Tomcat上java.lang.IllegalStateException: Optional int parameter 'id' is not present

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

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

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

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

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

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

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

  9. Jpa 报错 :HTTP Status 400 - Required String parameter 'xx' is not present

    一.问题描述 使用Springboot JPA 做分页查询,报错Required String parameter 'xx' is not present,后端未接受到请求 二.解决方案: 使用的请求 ...

随机推荐

  1. vue webpack build 打包过滤console.log()日志

    vue cli创建项目在 webpack.prod.conf.js文件 //打包时清除页面中所有打印及debugger断点 new webpack.optimize.UglifyJsPlugin({ ...

  2. io编程,python

    IO在计算机中指Input/Output,也就是输入和输出. Stream(流): 可以把流想象成一个水管,数据就是水管里的水,但是只能单向流动.Input Stream就是数据从外面(磁盘.网络)流 ...

  3. hive-pom.xml

    4.0.0 <groupId>com.cenzhongman</groupId> <artifactId>hive</artifactId> <v ...

  4. mysql安装与基本管理,mysql密码破解

    一.MySQL介绍 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下公司.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是 ...

  5. 关于requestMapping 进行url映射实现小小知识点 以及如何获取请求的url中的参数

    requstMapping 用来处理url映射  可以作用在controller类上  也可以作用在方法上 经常使用的方式  通过接收一种映射关系 @RequestMapping("/del ...

  6. istringstream输入数据到数组

    istringstream iss(line); ; while (!(iss >> dat[n]).fail()) n++;

  7. asp.net 常用几种下载方式

    protected void Button1_Click(object sender, EventArgs e) { /* 微软为Response对象提供了一个新的方法TransmitFile来解决使 ...

  8. 《Cracking the Coding Interview》——第4章:树和图——题目5

    2014-03-19 04:11 题目:设计算法检查一棵二叉树是否为二叉搜索树. 解法:既然是二叉搜索树,也就是说左子树所有节点都小于根,右子树所有节点都大于根.如果你真的全都检查的话,那就做了很多重 ...

  9. apt-get阿里源

    备份原有配置文件 mv /etc/apt/sources.list /etc/apt/sources.list.bak 新建一个文件 vi /etc/apt/sources.list 复制以下内容到新 ...

  10. Canvas 剪切图片

    /** * 剪切图像 */ function initDemo8(){ var canvas = document.getElementById("demo8"); if (!ca ...