package services; import org.directwebremoting.Browser; import org.directwebremoting.ScriptSessions; import org.directwebremoting.ServerContextFactory; import org.directwebremoting.ui.dwr.Util; public class HelloServices { public String sayHello(String name) { System.out.println("Hello now!"); reverserHello(); return "Hello " + name + "!"; } /** * 反推 */ public void reverserHello() { String page = ServerContextFactory.get().getContextPath() + "/dept.jsp"; Browser.withPage(page, new Runnable() { public void run() { ScriptSessions.addFunctionCall("divShow", "alert"); Util.setValue("result", "hello horizon!!!"); } }); } }
本文介绍了一个使用Direct Web Remoting (DWR) 的Java服务端示例,展示了如何通过DWR实现浏览器与Java服务端之间的交互,包括字符串反转操作及页面元素更新。
171

被折叠的 条评论
为什么被折叠?



