我的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基础之布尔运算、集合

    布尔值 True 真 False 假 所有的数据类型都自带布尔值,数据只有在0,None和空的时候为False. print(bool()) print(bool()) print(bool('')) ...

  2. ArrayList & Vector的源码实现

    #ArrayList & Vector #####前言: 本来按照计划,ArrayList和Vector是分开讲的,但是当我阅读了ArrayList和Vector的源码以后,我就改变了注意,把 ...

  3. SpringBoot推荐基础包

    技术交流群:233513714 Spring Boot 推荐的基础包 名称 说明 spring-boot-starter 核心 POM,包含自动配置支持.日志库和对 YAML 配置文件的支持. spr ...

  4. 5.bootstrap栅格 清除浮动

    只要用到栅格,就注意要清除浮动,清除方法就是在父元素的class上加一个clearfix 1.情景: . <div class="col-sm-7"> <div ...

  5. 底部菜单栏之Fragment的详细介绍和使用方法

    详情请看:http://blog.csdn.net/loongggdroid/article/details/9366413

  6. Pascal数据结构与算法

    第一章 数据结构与算法的引入 1.1 数据结构的基本概念 一. 学习数据结构的意义 程序设计 = 数据结构 + 算法 目前,80%的待处理的数据具有“算法简单”(四则运算.检索.排序等),“对象复杂” ...

  7. 为什么要搞vim

    一. 先得想清楚折腾vim受的这顿折磨值不值.值.零碎记录几点. 迫使我使用vim的原因如下: (1)之前实习的公司的开发机上只有vim,以后工作的公司也只有vim,同部门的同事大都用vim:如果不用 ...

  8. Linux编译安装与配置-MySQL(5.5,5.6)版本系(笔记)

    MySQL 5.5(5.6)后版本,需要使用cmake(Cross make , https://cmake.org/ )编译 我的环境如下: VMWare虚拟机,CentOS 5.5 x86_64( ...

  9. Vue组件编写

    Vue无疑是近来最火的一个前端框架,它吸取了angular1.x和react的精华,性能优良,而且易于上手,本文主要是关于如何去写一个组件. 首先是项目目录 编写组件 在这里我写了一个日期控件(移动端 ...

  10. 理解web缓存

    web缓存是web用于临时存储各种资源的一种技术. web缓存大概分两种,一种是前端缓存,另一种是后端端缓存. 前端缓存 浏览器缓存 浏览器自带的缓存机制. 比如说浏览器后退前进的动作,一般使用浏览器 ...