Spring-cloud-feign using @requetparam error querymap parameter must be a map:class java.lang.String

Source: Internet
Author: User

The spring-cloud-start-feign:1.2.2 realease version is used here, and the dependency manager version is CAMDEN.SR2

The reason for the error is that when the value of @requestparam is empty, the parameter is treated as a map

Org.springframework.cloud.netflix.feign.annotation.RequestParamParameterProcessor
The code is as follows:
    @Overridepublic boolean processargument (Annotatedparametercontext context,annotation Annotation) {Requestparam Requestparam = Annotation.cast (ANNOTATION); String name = Requestparam.value (); if (emptytonull (name) = null) {context.setparametername (name); Methodmetadata data = Context.getmethodmetadata (); collection<string> query = Context.settemplateparameter (Name,data.template (). queries (). Get (name)); Data.template (). Query (name, query);} else {//supports ' MAP ' typesmethodmetadata data = Context.getmethodmetadata ();d Ata.querymapindex ( Context.getparameterindex ());} return true;}    

  

Note that spring-cloud-feign handles @requestparam and spring MVC differently, and spring MVC reflects the name of the parameter as value when the value of @requestparam is empty.

Solution: Add value to @requestparam

Spring-cloud-feign using @requetparam error querymap parameter must be a map:class java.lang.String

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.