I have a request(POST or GET), having one variable “data” (coming from Xcode)
now data have assigned JSON object
data={"method":"Auth","action":"login"}
now I have a bean having exactly these two fields(i.e. method,action)
now in Spring controller I have method “login”.
I want this method to be invoked based on value in “action” of the request JSON object.
Now, I’m not getting what exactly types of annotation i should use.
Please help..
You need to add Jackson to the classpath, and add
<mvc:annotation-driven>to your Spring context, then Spring will automatically register aMappingJacksonHttpMessageConverterfor JSON Objects.Now Annotate your method like this:
(Both
YourRequestObjectandYourResponseObjectwill be automatically converted to and from JSON, but this works only for POST requests AFAIK)