2
此代碼適用於Chrome。但在Firefox中,它不會調用servlet。以下是代碼。我不知道這是否是瀏覽器差異。GWT formpanel適用於Chrome,但不適用於firefox
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();
xml文件如下。
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>`
要補充的FormPanel中的DOM任何面板? –
什麼是DOM?我是一名初學者。 Thx – user1415853
你在哪裏添加了面板? (類似於RootPanel.get()。add(formPanel)) –