I am doing a multipart request from a JavaScript script (AngularJS) and I get the JSON data as the first part, and an optional file as the second. Is it possible to have the @RequestParam("data") automatically converted from JSON to a class in my application? Like @RequestParam("data") Dog dog
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Yes. Use @RequestBody annotation before your object (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestbody):
Note: you must have jackson to convert json to your custom object. Jackson maven dependency:
Yes, you have to use Jackson. Use @RequestBody annotation for incoming parameter. Add dependency for codehous.jackson. And add JsonConverter to spring context file
By the way, you can take a look at the tutorial here. they use JSON and spring MVC: sites.google.com/site/upida4j/example
Define your method signature like this: