GWT可结合Struts,Spring,Hibernate共同进行web开发,在GWT中Struts、Spring、Hibernate使用的方式和SSH整合是一样的,可参照SSH开发框架的整合,而GWT和Struts整合可参照下面的url:
http://code.google.com/p/struts2gwtplugin/wiki/ZeroConfig
http://code.google.com/p/struts2gwtplugin/wiki/Howtouse
下载struts2gwtplugin(http://code.google.com/p/struts2gwtplugin),在struts.xml文件中添加如下package,并在其中配置
<package name="gwtrpc" extends="gwt-default">
<action name="listCategoryService" class="Action类名">
<interceptor-ref name="gwt"/>
</action>
</package>
其中action的实现类是server端的类,用户首先要在Client端中(包)定义用于异步通信的接口,然后server端的类实现该接口中定义的功能,类似GWT中异步通信创建的servlet。
具体的例子可参照 http://hgflybird.javaeye.com/blog/353636中写的异步调用的例子。
另:GWT生成的module页面之间参数的传递
一个GWT module对应一个html页面,若在两个html之间进行通信、传递参数,则可通过在GWT中调用JSNI函数和在html页面中使用<script>的window.location.search(获取从?开始的包括问号在内的参数字符串部分),获取参数!在GWT的Entry Point可调用JSNI函数获取页面传递的参数,具体使用方法如下:从而实现两个module之间参数的传递
/**
* Open a new window.
* @param url
*/
public static native void openNewWindow(String url)/*-{
$wnd.open(url);
}-*/;
/**
* Get Current Browser URL parameters string.
* @return
*/
public static native String getUrlParamStr()/*-{
return $wnd.location.search.substr(1);
}-*/;