📄 afficheaction.java
字号:
package com.action;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import com.actionForm.AfficheForm;
import org.apache.struts.actions.DispatchAction;
import com.dao.AfficheDao;
import com.tool.Chinese;
public class AfficheAction extends DispatchAction {
private Chinese chinese = new Chinese();
private AfficheDao afficheDao = new AfficheDao();
//前台操作
public ActionForward forntContentAfficheAction(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
request.setAttribute("form",afficheDao.selectOneAffiche(Integer.parseInt(request.getParameter("id"))));
return mapping.findForward("forntContentAfficheAction");
}
//后台操作
//删除公告信息
public ActionForward deleteAfficheAction(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
afficheDao.deleteAffiche(Integer.parseInt(request.getParameter("id")));
request.setAttribute("result", "删除公告信息成功!!!");
return mapping.findForward("resultAfficheAction");
}
//对公告信息的添加
public ActionForward insertAfficheAction(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
AfficheForm afficheForm = (AfficheForm) form;
if (afficheForm.getContent() == null ||
afficheForm.getContent().equals("")) {
return mapping.findForward("insertAfficheAction");
} else {
afficheForm.setCreateTime(afficheForm.getCreateTime());
afficheForm.setContent(chinese.toChinese(afficheForm.getContent()));
afficheForm.setTitle(chinese.toChinese(afficheForm.getTitle()));
afficheDao.insertAffiche(afficheForm);
request.setAttribute("result", "添加公告信息成功!!!");
return mapping.findForward("resultAfficheAction");
}
}
public ActionForward selectAfficheAction(ActionMapping mapping,
ActionForm form, //对公告信息的全部查询
HttpServletRequest request,
HttpServletResponse response) {
request.setAttribute("list", afficheDao.selectAffiche());
return mapping.findForward("selectAfficheAction");
}
//以自动编号为条件,查询公告信息
public ActionForward selectOneAfficheAction(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
request.setAttribute("form",
afficheDao.selectOneAffiche(Integer.
parseInt(request.getParameter("id"))));
if (request.getParameter("sign") == null ||
request.getParameter("sign").equals("")) {
return mapping.findForward("updateAfficheAction");
} else {
return mapping.findForward("selectContentAction");
}
}
//以自动编号为条件,修改公告信息
public ActionForward updateAfficheAction(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
AfficheForm afficheForm = (AfficheForm) form;
afficheForm.setCreateTime(afficheForm.getCreateTime());
afficheForm.setContent(chinese.toChinese(afficheForm.getContent()));
afficheForm.setTitle(chinese.toChinese(afficheForm.getTitle()));
afficheForm.setId(Integer.parseInt(request.getParameter("id")));
afficheDao.updateAffiche(afficheForm);
request.setAttribute("result", "修改公告信息成功!!!");
return mapping.findForward("resultAfficheAction");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -