解决办法:把基本类型改为对象,譬如此处将pageId的类型由int 改为Integer 2016-10-19 19:36:11.275 DEBUG [http-nio-9999-exec-2][org.springframework.web.servlet.DispatcherServlet] Last-Modified value for [/user/1/detail] is: -1 2016-10-19 19:36:11.278 DEBUG [http-nio-9999-exec-2][o…
我的spring mvc 代码: @Controller @RequestMapping("/product") public class Fancy { @RequestMapping(value = "/fancy") @ResponseBody public String showFancy(@RequestParam(value = "page", required = false) int page) { return "{\…
接口测试的时候遇到了一个问题,导致测试阻断了好久,在此记录,谨防忘记. 具体报错如下: Optional int parameter 'pId' 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. 接口…
错误的意思是: "可选的int参数'fundID'存在但由于被声明为基本类型而无法转换为空值" 意思是fundID被申明为int的基本数据类型, 不能转换为字符串的null值. 难道是在参数调用 的时候, 需要把fundID设置为对象类型吗? 答案是正确的. @RequestMapping(value = "/fund-purchase") public String fundPurchase(int fundID) { Fund fund = fundServic…
严重: Servlet.service() for servlet [note-portal] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Optional long parameter 'noteBookId' is present but cannot be translated into a n…
今天在操作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类型,前后设置的不一样,猜测前后需要设置一致,…
错误日志: java.lang.IllegalStateException: Optional int parameter 'resourceState' 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 typ…
问题描述: 好久不写博客了,今天遇到一个问题,那就是post请求时,参数接收不到,当时我很纳闷,看代码: 就是这样几个参数,我使用postman请求时无法获取参数: 报错信息: "msg":"Optional int parameter 'tableId' is present but cannot be translated into a null value due to 后来上网查了相关资料: 接口测试的时候遇到了一个问题,导致测试阻断了好久,在此记录,谨防忘记. 具体…
SpringMvc 中@RequestParam注解使用 建议使用包装类型来代替基本数据类型 public String form2(@RequestParam(name="age") int age){ public String form2(@RequestParam(name="age") Integer age) { 上述两种方式 这种情况下使用起来基本没有差别,但是为什么要说建议使用包装类型而不是基本类型呢? 一.@RequestParam属性作用 因为当…