当我使用这样的:
<portlet:resourceURL var="ajaxURL" id="ajax" escapeXml="false" />
$.ajax({
method : "POST",
url : "${ajaxURL}",
data : {
...
这不包括在它的工作原理页我的ajax调用里面。
inside my ajax call that is not included in page it works.
但是当我尝试包括页面上的同一个javscript code,我得到错误:
but when i try to include that same javscript code on page i get error:
WARN [http-bio-8080-exec-27][404_jsp:109] /$%7BajaxURL%7D
我的问题是如何在资源URL传递给包括JavaScript或如何在JavaScript的生成它。
My question is how to pass that resource url to included javascript or how to generate it within javascript.
我曾尝试:
VAR urlVar ='&LT; portlet中:resourceURL VAR =ajaxURLID =AJAX将escapeXml =FALSE/&GT;
当我使用urlVar上是这样的:
and when i use urlVar on this way:
$.ajax({
method : "POST",
url : urlVar,
data : {
...
它不工作。有谁知道如何解决这个问题呢?谢谢
It doesnt works. Does anyone knows how to solve this issue? Thanks
我已经找到了解决方案。这样做的一个方法是定义资源URL的JSP页面,例如是这样的:
I have found the solution. One way doing this is to define resource url on jsp page for example like this:
<portlet:resourceURL var="yourResourceURL" id="yourResource" />
和内放慢参数从JSP传递到位于外部的js文件中的函数。
and to pass it from jsp within paramter to the function that is located in external js file.
例如在JS:
function test(urlVar) {
alert(urlVar);
$.ajax({
method : "POST",
url : urlVar,
success : function(data) {
}
});
}
和在JSP中调用该函数是这样的:
and in jsp call that function like this:
test(" ${yourResourceURL} ");
和它应该工作。