【异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters

出现此异常原因是引文使用feign客户端的时候,参数没有用注解修饰

1.1GET方式
错误写法

@RequestMapping(value="/test", method=RequestMethod.GET)

Model test(final String name, final int age);

启动服务的时候,会报如下异常:

Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract com.chhliu.springboot.restful.vo.User com.chhliu.springboot.restful.feignclient.UserFeignClient.findByUsername(java.lang.String,java.lang.String)

异常原因:当使用Feign时,如果发送的是get请求,那么需要在请求参数前加上@RequestParam注解修饰,Controller里面可以不加该注解修饰。

正确写法

@RequestMapping(value="/test", method=RequestMethod.GET)

Model test(@RequestParam("name") final String name,@RequestParam("age") final int age);

1.1POST方式
错误写法

public int save(@RequestBody final Person p, @RequestBody final UserModel user);

feign中你可以有多个@RequestParam,但只能有不超过一个@RequestBody。

正确写法

public int save(@RequestBody final Person p,@RequestParam("userId") String userId,@RequestParam("userTel") String userTel);

原文地址:https://www.cnblogs.com/wbl001/p/11795859.html

时间: 2024-11-09 17:33:45

【异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters的相关文章

caused by: java.lang.IllegalStateException: Method has too many Body parameters: 多参数问题

https://blog.csdn.net/liuchuanhong1/article/details/54728681 多参数问题 @RequestMapping(value="/user/name", method=RequestMethod.GET)   User findByUsername(final String userName, final String address); 启动服务的时候,会报如下异常: Caused by: java.lang.IllegalStat

java.lang.IllegalStateException: Method get not annotated with HTTP method type (ex. GET, POST);

明明指定了请求方法类型还报错: 代码: @RequestMapping(value="/enterprise/detail",method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE) ResponseMsg get(@RequestBody RequestMsg req); 异常信息: java.lang.IllegalStateException: Method get not annotated

ssm项目——异常:Caused by: java.lang.IllegalStateException

异常:Caused by: java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource': no matching editors or conversion strategy found 大意:java.lang.String 与所需要的javax.sql.Data

Caused by: java.lang.IllegalStateException: Ambiguous mapping found

Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrController’ bean method 报错为:Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrController’ bean method 是因为两个请求,请求到同

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.mchange.v2.c3p0.ComboPooledDataSource] from ClassLoader [ParallelWebappClassLoader

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.mchange.v2.c3p0.ComboPooledDataSource] from ClassLoader [ParallelWebappClassLoader 020-04-11 18:49:17,914 WARN [org.springframework.web.context.support.XmlWebApplicationConte

Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError

SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.Exception in thread "main" java.lang.Exception

Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this respo

1.错误描述 Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:648) at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFa

Caused by: java.lang.IllegalStateException: The specified child already has a parent. You

ViewPager 报错:Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. 一中是removeView这个问题很常见的,具体解决方法就不谈了,另外一种是情况如下: adapter=new ViewPagerAdapter(Views); views>>  view

Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3939

在使用Gson解析JSON数据时,报错:Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3939 原因:传入的参数有问题: while((len=inputStream.read(data))!=-1){ outPutStream.write(data,0,len); } 错写成: while((len=inputStream.read())!=-1