开发者

jQuery not working with struts2 actions

Is it a must to use the struts2-jquery plugin to be able to run jQuery code in a struts2 application?

I am working on a struts2 web app

jQuery file: WebContent/js/jquery-1.4.3.js

JSP pages location: WebContent/pages/*.jsp

THDFindYourQuote.jsp is the default page of the application:

I have a simple script in THDFindYourQuote.jsp

[script type="text/javascript" src="../js/jquery-1.4.3.js"][/script]

[script type="text/javascript"]

$(document).ready(function(){

alert('I am in the JSP code now!!');

});

The above script is executed when i access the url:

localhost:8081/ CloseQuote/pages/THDFindYourQuote.jsp

the same script does not work when I access the URL:

localhost:8081/ CloseQuote/

I am having the same problem in o开发者_运维问答ther JSPs. The script works when i access the jsp using the full path URL. It does not work when I access the jsp with action urls ..please help


Is it a must to use the struts2-jquery plugin to be able to run jQuery code in a struts2 application?

No. I don't use that plugin and I use jQuery in all of my Struts2 applications. Just include it in the UI layer the same as you would in a PHP application, a Ruby application, etc.

It looks like the problem is that you are using relative URLs. Try using absolute ones.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜