开发者

Ajax url inside java script in struts 2.0

how to开发者_StackOverflow社区 use Ajax url inside java script in struts 2.0.

For example for servlets we write url= ControllerServlet?ActionId=myJsp

similarly how to write for struts 2.

Thanks in advance.


i got the answer.

the url will be -

url= Controller.action?param="value"


xmlHttp.open("GET","yourNameSpace/yourActionName?property=value1&property2=value2",true);

xmlHttp.send();

Don't get confused by yourNameSpace in the above

Check your namespace attribute of package tag in struts.xml/struts-config.xml file and give the same there.

If you want to send parameters separately use post ajax request given below.

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);
}

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜