user5157427 user5157427 - 4 months ago 33
Java Question

POST method that accept few arguments

Is it possible to write a @POST method that accept few arguments , some objects some primitive ? like this :

public String postMessage(Message msg,Car car,String s,int i) throws Exception{

if yes - how will the request body looks like ?

Thank you


It is possible by creating a wrapper container class for input. e.g.

class PostInput{
  private Message message,
  private Car car;
  private String s;
  private int i;

  // getters and setters for properties

then the signature of method will be

public String postMessage(PostInput input)

You'd need to form the corresponding json object in the client