#眉標=Ajax #副標=AJAX開發工具(7) #大標=整合GWT與Struts #作者=文/沈炳宏 ==程式1 =========== action *.gwt ================ ==程式2 =========== ================ ==程式3 =========== ================ ==程式4 =========== action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml    action *.gwt /WEB-INF/jsp/index.jsp ================ ==程式5 =========== ================ ==程式6 =========== ================ ==程式7 =========== StrutsDemo 編譯檔 ================ ==程式8 =========== ================    ==程式9 =========== struts2 struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* index.html ================ ==程式10 =========== ================ ==程式11 =========== package demo; import java.util.*; public class Hello { public String execute(String text) { GregorianCalendar calendar = new GregorianCalendar(); String result = text + ": " + calendar.getTime().toString(); return result; } } ================ ==程式12 =========== package com.runpc.client; public interface MyService extends RemoteService { public String execute(String s); } package com.runpc.client; public interface MyServiceAsync { public void execute(String s, AsyncCallback callback); } ================ ==程式13 =========== m_clickMeButton.addClickListener( new ClickListener() { public void onClick(Widget sender) { MyServiceAsync service = (MyServiceAsync) GWT   .create(MyService.class); AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) {   label.setText(result.toString()); } public void onFailure(Throwable caught) { label.setText(caught.toString()); } }; ServiceDefTarget endpoint = (ServiceDefTarget) service; endpoint.setServiceEntryPoint("Hello.action"); service.execute(textBox.getText(), callback); } }); ================      =========box作者介紹==========   沈炳宏   台灣微軟3-1/4-1/5-1/6-1MVP,長庚資管所畢業,致力於各軟體開發技術的研究,現任職為軟體工程師。   =============end===============