Spring 3 JSON with MVC

前端 未结 8 955
温柔的废话
温柔的废话 2020-12-23 02:33

Is there a way to build Spring Web calls that consume and produce application/json formatted requests and responses respectively?

Maybe this i

相关标签:
8条回答
  • 2020-12-23 02:58

    You can configure Spring MVC interceptors through handler mappings and then use the mappings to transform the returning data to JSON. The handler configuration can be done in xml (no need to recompile), and this can be completely transparent to the rest of the application.

    It's fairly easy to annotate controllers with some annotation, and then hook up the BeanFactory bootstrap process to register the controllers within some handler mapping process.

    I have used this approach to transform the result from spring controllers into GWT RPC calls.

    You can also use Spring AOP to intercept controller method calls and unwrap/wrap the requests from/to JSON.

    0 讨论(0)
  • 2020-12-23 03:00

    You can certainly have controllers that return a View which is in JSON output. Take a look at the Spring-JSON project.

    To consume requests in JSON I would assume you would just want a controller to pass a request parameter off to a JSON library which could parse the data?

    0 讨论(0)
提交回复
热议问题