?? 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 + -