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

Posted Wsnan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了caused by: java.lang.IllegalStateException: Method has too many Body parameters: 多参数问题相关的知识,希望对你有一定的参考价值。

https://blog.csdn.net/liuchuanhong1/article/details/54728681

多参数问题

 

    1. @RequestMapping(value="/user/name", method=RequestMethod.GET)
    2.  
      User findByUsername(final String userName, final String address);

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

 

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="/user/name", method=RequestMethod.GET)
User findByUsername(@RequestParam("userName") final String userName, @RequestParam("address") final String address);

 

以上是关于caused by: java.lang.IllegalStateException: Method has too many Body parameters: 多参数问题的主要内容,如果未能解决你的问题,请参考以下文章

Hang caused by GC

Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:20880 Caused by: ja

Mathematical Problems Caused by CCD

Caused by SSLError

Caused by: java.lang.NoClassDefFoundError:

caused by a circular import.