GWT:我可以在浏览器中调用 servlet。当我通过formpanel调用它时,它可以调用onSubmit。但它不会调用 onSubmitComplete。它还会弹出一个新窗口,uri 是我的 servlet。
String URL= GWT.getModuleBaseURL()+"getType";
FormPanel formPanel = new FormPanel();
formPanel.setAction(URL);
formPanel.setEncoding(FormPanel.ENCODING_URLENCODED);
formPanel.setMethod(FormPanel.METHOD_GET);
formPanel.addSubmitHandler(new SubmitHandler(){
@Override
public void onSubmit(SubmitEvent event) {
// TODO Auto-generated method stub
System.out.println(event.getSource());
}
});
formPanel.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
System.out.println("in");
System.out.println(event.getResults());
}
});
formPanel.submit();
GWT.xml
<servlet class="msp2.server.getType" path="/getType" />
web.xml
<servlet >
<servlet-name>getType</servlet-name>
<servlet-class>msp2.server.getType</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>getType</servlet-name>
<url-pattern>/msp2_app/getType</url-pattern>
</servlet-mapping>