GWT + Spring MVC(RESTful Web服务) [英] GWT + Spring MVC (RESTful web services)

查看:145
本文介绍了GWT + Spring MVC(RESTful Web服务)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑如何使用GWT来设置Spring MVC 3.0(更具体地说是REST功能)。也就是说,我不想再使用GWT RPC,通信将通过REST完成。问题是,我对Spring Framework非常新,而且我发现了唯一的教程,他们使用的是JSP,这正是我陷入困境的地方......有没有一种方法可以与没有JSP页面的Spring一起玩,只能使用GWT视图?

解决方案

我假设你试图做的是让Spring控制器返回JSON或XML数据?

有两种方法可以做到这一点:


  1. 使用ContentNegotiatingViewResolver li>
  2. 将HttpMessageConverters与@ResponseBody注释组合使用


    这两种方法在这里有一些细节: http://hillert.blogspot.com/2011/01/rest -with-spring-contentnegotiatingview.html



    春季人们在这里覆盖了@RequestBody方法: http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring -3-0 /



    以下是涵盖ContentNegotiatingViewResolver的博客文章: http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/



    鳕鱼样本e可以在以下网址找到: https://src.springframework.org/ svn / spring-samples / mvc-ajax / trunk /

    我希望这有帮助。

    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 to 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.

    这篇关于GWT + Spring MVC(RESTful Web服务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆