📄 addafficheaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.oa.personaloffice.action;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.oa.db.Affiche;
import com.oa.db.AfficheDAOImpl;
import com.oa.personaloffice.form.AfficheForm;
/**
* MyEclipse Struts
* Creation date: 09-06-2007
*
* XDoclet definition:
* @struts.action validate="true"
*
*
* @author 陈召富 2007年10月10
*
* @author 李海红 2007年10月24
*
*/
public class AddAfficheAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
private Affiche affiche;
private AfficheDAOImpl afficheDao;
public void setAfficheDao(AfficheDAOImpl afficheDao) {
this.afficheDao = afficheDao;
}
public void setAffiche(Affiche affiche) {
this.affiche = affiche;
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
AfficheForm afficheForm = (AfficheForm) form;
response.setCharacterEncoding("gbk");
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
HttpSession session = request.getSession();
String empId = session.getAttribute("username").toString();
if(empId!=null){
affiche.setDeptId(afficheForm.getDeptId());
affiche.setAfficheContent(afficheForm.getAfficheContent());
affiche.setAfficheTitle(afficheForm.getAfficheTitle());
affiche.setEmpId(empId);
afficheDao.addAffiche(affiche);
try {
response.sendRedirect("showAfficheByDeptId.do");
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}else{
out.print("<script>alert('您的操作超时,请重新登录!');");
out.print("window.open('login.jsp','_top');");
out.print("</script>");
out.flush();
out.close();
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -