GWT + Spring MVC (RESTful web services)
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:
- use a ContentNegotiatingViewResolver
- 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.
精彩评论