@FormParam of jaxrs cannot pass arguments
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
Description
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
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 !
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the JAXRSContract and Feign.builder configuration shown in the issue, then trace how @FormParam reaches feign.jackson.JacksonEncoder. Compare the intended application/x-www-form-urlencoded request with the encoder's output; done means the username argument is sent as form data rather than JSON, with a reproducible test or documented configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100