【发布时间】:2011-01-18 08:58:02
【问题描述】:
我需要在加载 JSP 时调用一个动作。跟踪访问该页面的用户数量。
我有一个操作VisitorCounterAction,它会更新数据库。
在加载 JSP 时,我正在调用 ajax 函数 callCounter();
{
alert("callCounter");
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
// i need some correction here
xmlhttp.open("GET",VisitorCounterAction,false);
xmlhttp.send(null);
alert("callCounter returned from Action");
}
我得到一个例外:
/web/guest/content?p_p_id=31&p_p_lifecycle=0&p_p_state=pop_up&p_p_mode=view&_31_struts_action=%2Fimage_gallery%2Fview_slide_show&_31_folderId=10605 生成异常:null
请帮我解决这个问题。或任何其他方式来调用动作。 我无法重新加载页面,因为它会再次调用 onload 函数。
谢谢, DJ
【问题讨论】:
-
为什么“p_p_state”的值为“pop_up”?
-
您是否对您的操作类代码进行了单步调试?你在哪里得到空错误?我正在使用 Struts 1.3 进行一些 AJAX 调用,并且我没有在我的操作类中做任何特别的事情,所以我猜你的问题可能与你发送的参数有关。
标签: java javascript ajax struts