如何在WebBrowser中的Javascript代码和Java代码之间传递信息
我有一个嵌入式WebBrowser,其中添加了LocationListener如何在WebBrowser中的Javascript代码和Java代码之间传递信息,java,javascript,browser,swt,Java,Javascript,Browser,Swt,我有一个嵌入式WebBrowser,其中添加了LocationListener mywebBrowser.addLocationListener(new LocationListener(){ public void changing(LocationEvent event){ event.getLocation() } }) ; 在这个WebBrowser中,我有一个可以输入文本的表单。我还有一个链接,允许用户导航到其他页面 <form method="get"
mywebBrowser.addLocationListener(new LocationListener(){
public void changing(LocationEvent event){
event.getLocation()
}
}) ;
在这个WebBrowser中,我有一个可以输入文本的表单。我还有一个链接,允许用户导航到其他页面
<form method="get" action="{$self}" name="addcommentform">
<textarea title="{$enterComment}" name="comment" class="commentarea" </textarea>
<input class="Button" type="submit" value="{$postComment}" />
</form>
您可以从Java类(servlet、JSP、Struts操作等)获取get或POST参数
例如,如果要从Servlet获取get参数,可以使用:
public class ThreeParams extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String comment = request.getParameter("comment");
// Do something with the value
}
}
您在WebBrowser组件上尝试过getDocument()方法吗?我不确定这是否得到实时更新,但可能值得一看。您使用什么API或框架来获得WebBrowser?我使用的是Eclipse插件框架。我正在使用com.ibm.rcp.browser.service.WebBrowser;