Reputation: 678
I cannot make my controller working when I add additional parameter when I have HttpServletRequest
as one of its parameters. The following code compiles and gives no exceptions.
@POST
@Path("new")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String create(HttpServletRequest request) {
}
However, when I add additional parameter, an exception is thrown.
@POST
@Path("new")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String create(HttpServletRequest request, ClientDto clientDto) {
}
Here's the exception:
[[FATAL] Method public java.lang.String CreditController.create(
javax.servlet.http.HttpServletRequest,dto.ClientDto) on resource class CreditController
contains multiple parameters with no annotation.
Unable to resolve the injection source.;
Upvotes: 1
Views: 243
Reputation: 2231
As per suggestion of @GyroGearless:
It seems to missing @Context
annotation, you can try with this like,
@POST
@Path("new")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String create(@Context HttpServletRequest request, ClientDto clientDto) {
Upvotes: 1