2

I want to add request mapping my controller which gets a Json of Array of an object. The JSON will be sent from javascript using post.

Thanks, Kfir

1 Answer 1

2

You can do this using Spring's @RequestBody annotation, e.g.

@ResponseBody
public Map<String, Object> handleJsonPost(@RequestBody Map<String, Object> requestJson) {
   ...
   return responseJson;
}

This will also send the return value back as JSON.

You'll also need to include the Jackson library in your application's classpath, and add

<mvc:annotation-driven/> 

to your context (see docs)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.