0
How do I access the body content of the request sent by the client? For example:
@Override
@GET
@Path("/mypath")
public Response myMethod() {
System.out.println("Conteúdo da requisição: " + request.body);
return null;
}
0
How do I access the body content of the request sent by the client? For example:
@Override
@GET
@Path("/mypath")
public Response myMethod() {
System.out.println("Conteúdo da requisição: " + request.body);
return null;
}
Browser other questions tagged java restful resteasy
You are not signed in. Login or sign up in order to post.
Try to put
@Context HttpServletRequest request
as a parameter of the method.– Gustavo Cinque
I even tried, as I have seen in several similar problems. Only the eclipse cannot see the references and does not recognize the Class. In the end, it always gives
java.lang.ClassNotFoundException: HttpServletRequest
– Hamurabi Araujo
Even looking for the class (
Ctrl + T
) can’t find?– Gustavo Cinque
Unfortunately, no :(
– Hamurabi Araujo
The eclipse is not happening
import
of no lib that comes fromjavax.servlet.*
. For some reason, you don’t recognize.– Hamurabi Araujo
Can you add dependencies to the project? Try inserting that one.
– Gustavo Cinque
The right thing would be that one in fact. But there you see your need.
– Gustavo Cinque
The import worked with the second reference, but I followed some links on Soen - here, for example - I didn’t get any return.
– Hamurabi Araujo
request is loaded when it enters the method?
– Gustavo Cinque
@Gustavocinque, I was able to solve the problem by adding your lib suggestion to what is cited in that reply
– Hamurabi Araujo
Cool, @Hamurabiaraujo. Even though I don’t understand how to check if the method used is
POST
or would not help you. But even so, a tip, classjavax.ws.rs.HttpMethod
keeps enums for the most common methods (POST
,GET
,PUT
,DELETE
,HEAD
andOPTIONS
). It is worth using and not having to make the comparison with raw string.– Gustavo Cinque
It is because it really does not make sense to exist this verification. Now that you spoke, I went to analyze right (rsrs). Because the method only accepts request
@POST
, then there is no need for such a test within the method itself.– Hamurabi Araujo