user8966659
user8966659

Reputation:

Get raw json string in Spring MVC Rest

Im have @RestController and this method. how can I get any json and then select the handler depending on the method and pass it there for processing PS. I use GSON instead of JACKSON

Method

Upvotes: 1

Views: 630

Answers (1)

mikeb
mikeb

Reputation: 11307

You can use @RequestBody in your method and take a String parameter:

public AbstractJsonResponse(@PaqthVariable String method, @RequestBody String json) {
  ...
}

See here: https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/bind/annotation/RequestBody.html

Mainly the part that says:

Annotation indicating a method parameter should be bound to the body of the web request

Upvotes: 1

Related Questions