我的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. Python IO关于mode参数的问题

    关于open()的mode参数: 'r':读 'w':写 'a':追加 'r+' == r+w(可读可写,文件若不存在就报错(IOError)) 'w+' == w+r(可读可写,文件若不存在就创建) ...

  2. SQLite3中dos命令下退出"...>"状态的方法

    今天在看Android中SQLite,跟着书上一步一步走,在dos中敲命令时候不小心敲错了,命令行就会突然变成”…>”这样的,本来是”sqlite>”的,然后接下来后面的就没办法在继续操作 ...

  3. ssh-debian87.sh

    #!/bin/bash sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config s ...

  4. 2 25urllib.py

    """ urllib.request.urlopen(url,data,timeout) """ # from urllib.request ...

  5. Qt Creator : Read an image from resources

    最近两周碰到的一个问题是: opencv无法读取qt中的资源文件. 参考网址:https://stackoverflow.com/questions/45233559/qt-creator-read- ...

  6. 01、JAVA开发准备

    一.首先要认识几个名词: 1. JRE(Java Runtime Environment ,JAVA运行环境):它包含Java虚拟机(JVM,Java Virtual Machine)和Java程序所 ...

  7. Axure+SVN——实现多人团队开发

    最近进行考试系统重构,一个小组十几个人,这么多人要同时搞需求画原型.这样原本的合作开发工具SVN已经不能满足现在的需求了,这是就找到了一个新的方法--Axure+SVN. 在SVN服务器端建立一个空的 ...

  8. idea中新建的web项目不能新建servlet

    ============ ======================================================================== 在新建的“ java ”源文 ...

  9. hdu 2899 Strange fuction (二分法)

    Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  10. 树上莫队 SPOJ COT2

    题意: 给一棵树,每次查询u到v路径上有多少不同的点权 首先需要证明这类题目符合区间加减性质 摘选一段vfk大牛的证明 用S(v, u)代表 v到u的路径上的结点的集合. 用root来代表根结点,用l ...