Skip to content

@FormParam of jaxrs cannot pass arguments #2135

@zhanjinhao

Description

@zhanjinhao

jaxrs version: 3.0.7.Final
feign version: 11.10

I want to use @FormParam to pass arguments, and this is my code :

server:

    @POST
    @Path("/system/authentication/findGroupByUserName")
    List<Group> findGroupByUserName(@FormParam("username") String string);

client, service:

    @POST
    @Path("/system/authentication/findGroupByUserName")
    @Headers(value = {" content-type : application/x-www-form-urlencoded "})
    List<Group> findGroupByUserName(@FormParam("username") String string);

client feign builder:

  Feign.builder()
            // required values 
            .logger(new Slf4jLogger(type))
            .client(new ApacheHttpClient(HttpClientUtils.getHttpClient()))
            .contract(new JAXRSContract())
            .encoder(new JacksonEncoder())
            .decoder(new JacksonDecoder())
            .options(options);

My JAXRSContract class is copy from feign-jaxrs peoject and I wrote some code so that it can parse the @Headers annotation.
Now my issue is that the argument usename is encode to json instead of form.
I have traced the code and found the code below : feign.jackson.JacksonEncoder#encode
image

The data format of the form is: username = '123456', but the data format of the json is {"username":"123456"}. So how can i config the feign builder to make it work , or is there some other solutions.

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    feedback providedFeedback has been provided to the authorquestionGeneral usage or 'how-to' questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions