如何在struts 2.0中的java腳本中使用Ajax url。支持struts 2.0的java腳本中的Ajax url
例如對servlet我們寫 URL = ControllerServlet中?ActionId = myJsp
類似於如何爲支柱2.
在此先感謝寫。
如何在struts 2.0中的java腳本中使用Ajax url。支持struts 2.0的java腳本中的Ajax url
例如對servlet我們寫 URL = ControllerServlet中?ActionId = myJsp
類似於如何爲支柱2.
在此先感謝寫。
我得到了答案。
將URL -
URL = Controller.action PARAM = 「值」
xmlHttp.open("GET","yourNameSpace/yourActionName?property=value1&property2=value2",true);
xmlHttp.send();
不要被yourNameSpace在上述
混淆檢查?命名空間屬性包在struts.xml/struts-config.xml文件中標記並在那裏給出相同的標記。
如果要單獨發送參數,請使用以下給出的post ajax請求。
var params = "property1=value1&property2=value2";
xmlhttp.open("POST","yourNameSpace/yourActionName",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
}
希望這會有所幫助。