我在页面中有这样一条javascript语句:setTimeout(doOperate('doGame'), 5000);但是发现其中的doOperate('doGame')方法
执行了,但是程序根本没有停滞.如果改成这样:setTimeout("doOperate('doGame')", 5000);就出现错误提示:
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.NoSuchMethodException: Action[/petInfo] does not contain specified method (check logs)
root cause
java.lang.NoSuchMethodException: Action[/petInfo] does not contain specified method (check logs)
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.
而我的/petInfo对应的Action中也正确定义了doGame 方法
执行了,但是程序根本没有停滞.如果改成这样:setTimeout("doOperate('doGame')", 5000);就出现错误提示:
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.NoSuchMethodException: Action[/petInfo] does not contain specified method (check logs)
root cause
java.lang.NoSuchMethodException: Action[/petInfo] does not contain specified method (check logs)
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.
而我的/petInfo对应的Action中也正确定义了doGame 方法
但是你的struts2配置文件有问题,获取你请求的url地址错误了
没有这个方法,说明Js那里执行了啦。看看配置咯~
public ActionForward doGame(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String itemIdStr = request.getParameter("ItemId");
int itemId = Integer.valueOf(itemIdStr);
impleItemBiz.doThing(itemId, "game");
response.sendRedirect("show.do?id=" + itemId);
return null;
}
配置文件
<action name="dynaLoginForm" path="/itemInfo" scope="request" type="strutsActions.ItemInfoAction" parameter="operate" validate="false">
<forward name="index" path="/index.jsp"/>
<forward name="showItem" path="/WEB-INF/jsp/item/itemInfo.jsp"/>
</action>
第二,配置问题说明了你的方法里面没有定义的方法,看了你确实有doGAme的方法,那就是可能你的配置上出现了错误,没有对应你传过去的PetINfo这个配置
所以他就没用经过Struts进行继续工作