📄 secondquestionaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.accphr.web.action;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.accphr.biz.IFirstQuestionBiz;
import com.accphr.biz.ISecondQuestionBiz;
import com.accphr.entity.SecondQuestion;
import com.accphr.page.PageResult;
import com.accphr.web.form.SecondQuestionForm;
public class SecondQuestionAction extends DispatchAction {
private ISecondQuestionBiz secondQuestionBiz;
private IFirstQuestionBiz firstQuestionBiz;
public void setFirstQuestionBiz(IFirstQuestionBiz firstQuestionBiz) {
this.firstQuestionBiz = firstQuestionBiz;
}
public void setSecondQuestionBiz(ISecondQuestionBiz secondQuestionBiz) {
this.secondQuestionBiz = secondQuestionBiz;
}
//显示信息
public ActionForward toList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SecondQuestionForm secondQuestionForm = (SecondQuestionForm) form;
PageResult pageResult=secondQuestionForm.getPageResult();
this.secondQuestionBiz.setPageResult(null, pageResult);
secondQuestionForm.setPageResult(pageResult);
return mapping.findForward("tolist");
}
//添加信息
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
SecondQuestionForm secondQuestionForm = (SecondQuestionForm) form;
SecondQuestion secondQuestion =secondQuestionForm.getSecondQuestion();
System.out.println(secondQuestion.getFirstKindId());
String newid=this.secondQuestionBiz.findNewId(secondQuestion.getFirstKindId());
secondQuestion.setSecondKindId(newid);
this.secondQuestionBiz.add(secondQuestion);
PrintWriter out=response.getWriter();
out.print("<script>alert('添加成功');location.href='secondQuestion.do?opsq=toList'</script>");
return null;
}
//到添加页面
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SecondQuestionForm secondQuestionForm = (SecondQuestionForm) form;
List list=this.firstQuestionBiz.findAll(null);
request.setAttribute("firstlist", list);
return mapping.findForward("toadd");
}
//删除
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
SecondQuestionForm secondQuestionForm = (SecondQuestionForm) form;
Short sqid=Short.parseShort(request.getParameter("sqid"));
this.secondQuestionBiz.del(sqid);
PrintWriter out=response.getWriter();
out.print("<script>alert('删除成功');location.href='secondQuestion.do?opsq=toList'</script>");
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -