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.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][org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod] Error resolving argument [1] [type=int]
HandlerMethod details:
Controller [com.rest.RestTemplateDemo]
Method [public com.rest.Result com.rest.RestTemplateDemo.getPathVariableAndRequestParameter(java.lang.String,int,int)]

java.lang.IllegalStateException: Optional int parameter 'pageId' 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.
    at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.handleNullValue(AbstractNamedValueMethodArgumentResolver.java:205) ~[spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:98) ~[spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77) ~[spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162) [spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:129) [spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:111) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:799) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:728) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845) [spring-webmvc-4.2.0.RC1.jar:4.2.0.RC1]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at com.global.filter.RewriteServletPathFilter.doFilter(RewriteServletPathFilter.java:25) [classes/:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at com.global.filter.AddExtraToParamsFilter.doFilter(AddExtraToParamsFilter.java:33) [classes/:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) [spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.0.RC1.jar:4.2.0.RC1]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.23.jar:8.0.23]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
2016-10-19 19:36:11.280 DEBUG [http-nio-9999-exec-2][org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] Resolving exception from handler [public com.rest.Result com.rest.RestTemplateDemo.getPathVariableAndRequestParameter(java.lang.String,int,int)]: java.lang.IllegalStateException: Optional int parameter 'pageId' 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.
2016-10-19 19:36:11.281 DEBUG [http-nio-9999-exec-2][org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'exceptionHandleAdvice'

 

时间: 2024-11-02 16:47:52

is present but cannot be translated into a null value due to being declared as a primitive type的相关文章

Gradle-Android打包文档

http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Android-tasks Gradle Plugin User Guide Contents 1 Introduction 1.1 Why Gradle? 2 Requirements 3 Basic Project 3.1 Simple build files 3.2 Project Structure 3.2.1 Configuring the Struct

Tomcat源码阅读#3:Server初始化与启动

b) Catalina.load() b1) initDirs() -> set properties like catalina.home catalina.base == catalina.home (most cases) b2) initNaming setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, org.apache.naming.java.javaURLContextFactory ->default) b3) c

BigDecimal

/* * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ /* * Portions Copyright IBM Corporation, 2001. All Rights

SpringMVC注解@RequestParam全面解析

在SpringMVC后台控制层获取参数的方式主要有两种,一种是request.getParameter("name"),另外一种是用注解@RequestParam直接获取.这里主要讲这个注解  一.基本使用,获取提交的参数 后端代码:  Java代码   @RequestMapping("testRequestParam")        public String filesUpload(@RequestParam String inputStr, HttpSer

@AspectJ support (good)

AspectJ类型匹配的通配符:*:匹配任何数量字符:..:匹配任何数量字符的重复,如在类型模式中匹配任何数量子包:而在方法参数模式中匹配任何数量参数.+:匹配指定类型的子类型:仅能作为后缀放在类型模式后边.java.lang.String 匹配String类型:java.*.String 匹配java包下的任何"一级子包"下的String类型://*只能匹配一个子包如匹配java.lang.String,但不匹配java.lang.ss.Stringjava..* 匹配java包及任

Android自动连接指定的wifi,免密码或指定密码

原文:Android自动连接指定的wifi,免密码或指定密码 一.运行时的状态 遇到一个这样的要求:"不进行扫描操作,怎么对指定的免密码WIFI进行连接(之前没有连接过)",于是动手写了一个Demo,如图所示未连接成功时的状态,第一个编辑框让用户输入SSID,第二个编辑框输入密码,密码可以根据实例情况输入,也可以不输入密码,因为有些Wifi免密码.这里的免密码不是指可以破解wifi密码.注意图片中手机顶部的wifi图标,是没有的,说明此时并没有打开手机的wifi.在手机上运行状态如下所

Java Memory Model

[原文地址] The Java memory model specifies how the Java virtual machine works with the computer's memory (RAM). The Java virtual machine is a model of a whole computer so this model naturally includes a memory model - AKA the Java memory model. It is ver

PostgreSQL pg_backup_start_time() CST 时区转换 问题

PostgreSQL的物理备份方法之一 :在使用pg_start_backup()函数新建备份点后,用户可以开始拷贝PG的数据文件. postgres=# select pg_start_backup('a'),now(); pg_start_backup | now -----------------+------------------------------- 0/50000028 | 2016-05-06 11:03:30.917509+08 (1 row) 调用pg_start_bac

10个鲜为人知的C#关键字

10 Not So Well Known Keywords in C# Ok before the flaming start let me state this. These are known to most hardcore programmers and not knowing them doesn't make you less of a programmer either. That said these keywords can come in handy and allow fo