开发者

URL Parameters and AJAX Problem

I have a JSP page that when loaded calls a JavaScript function (loadData()), this function uses an AJAX request to retrieve data from a servlet and return the necessary HTML content to the page.

I want to call this url from a button and pass a URL Parameter (....jsp?name=joe), I can do t开发者_如何学编程his, but when I try to retrieve it from the servlet I can only see the parameters passed in the AJAX Request, not the parameter in the URL...

Is there a reason this is happening? Should I go about this a different way?

Thank you!


It sounds like as if the Ajax request is actually a HTTP POST request. This way the GET query string in URL will indeed not be parsed. You need to parse it yourself in the doPost() method of the servlet. It's available by HttpServletRequest#getQueryString().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜