开发者

GWT + Spring MVC (RESTful web services)

开发者 https://www.devze.com 2023-02-06 18:43 出处:网络
I\'ve been thinking all the day about how I can setup Spring MVC 3.0 (more specifically REST capabilities), with GWT. That is, I don\'t wanna use GWT RPC anymore, the communication will be made throug

I've been thinking all the day about how I can setup Spring MVC 3.0 (more specifically REST capabilities), with GWT. That is, I don't wanna use GWT RPC anymore, the communication will be made through REST. The problem is that I'm very new with the Spring Framework, and the only tutorials I found, they were using JSP, that's exactly where I get stuck... Is there a way t开发者_C百科o play with Spring without JSP page, only using the GWT view?


I assume what your trying to do is have a Spring controller return JSON or XML data?

There are two ways to do this:

  1. use a ContentNegotiatingViewResolver
  2. use HttpMessageConverters in combination with the @ResponseBody annotation

Both methods are covered in some detail here : http://hillert.blogspot.com/2011/01/rest-with-spring-contentnegotiatingview.html

The spring people cover the @RequestBody method here: http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/

Here is the blog post covering the ContentNegotiatingViewResolver : http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/

Sample code can be found at : https://src.springframework.org/svn/spring-samples/mvc-ajax/trunk/

I hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号