用SSH做的系统,想实现点击后自动加分的功能。
public void updateAccept(int accept,int qid) throws Exception {
Session session = super.getSession();
String hql = "UPDATE Question SET acceptflag=? WHERE qid=?";
Query q = session.createQuery(hql);
q.setInteger(0, accept);
q.setInteger(1, qid);
q.executeUpdate();
releaseSession(session);
}这是数据操作的代码。
struts中action的代码为:
public ActionForward acceptquestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 已经采纳答案:accpetflag = 1
AdminquestionForm adminquestionForm = (AdminquestionForm) form;
int qid = Integer.parseInt(request.getParameter("qid")) ;
try {
this.iquestiondao.updateAccept(1,qid) ;
}
catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
}
return mapping.findForward("updatequestiondo");
}
页面中就是用<html:form>标签来写的,但是奇怪的是报错:java.lang.StackOverflowError。但是数据库里的内容已经被写进去了
在网上查了资料说这个错误是递归引起,但是没发现什么递归啊,很郁闷啊,求高手!
public void updateAccept(int accept,int qid) throws Exception {
Session session = super.getSession();
String hql = "UPDATE Question SET acceptflag=? WHERE qid=?";
Query q = session.createQuery(hql);
q.setInteger(0, accept);
q.setInteger(1, qid);
q.executeUpdate();
releaseSession(session);
}这是数据操作的代码。
struts中action的代码为:
public ActionForward acceptquestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 已经采纳答案:accpetflag = 1
AdminquestionForm adminquestionForm = (AdminquestionForm) form;
int qid = Integer.parseInt(request.getParameter("qid")) ;
try {
this.iquestiondao.updateAccept(1,qid) ;
}
catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
}
return mapping.findForward("updatequestiondo");
}
页面中就是用<html:form>标签来写的,但是奇怪的是报错:java.lang.StackOverflowError。但是数据库里的内容已经被写进去了
在网上查了资料说这个错误是递归引起,但是没发现什么递归啊,很郁闷啊,求高手!
比如,action处理完返回时又重定向到这个action。这样也是递归(不容易发现)
这个地方的问题吗?