📄 trainintentaction.java
字号:
package org.HumResManSys.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.HumResManSys.actionForm.Emp_trainForm;
import org.HumResManSys.factory.ServiceFactory;
import org.HumResManSys.vo.Emp_train;
import org.HumResManSys.vo.Employee;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
public class TrainIntentAction extends DispatchAction {
private ServiceFactory serviceFactory;
Log log=LogFactory.getLog(TrainIntentAction.class);//log.debug
//添加一条意向信息
public ActionForward addTrainIntent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
//插入数据库
boolean OKOrNot;
try {
//获取表单内容
Emp_trainForm intent=(Emp_trainForm)form;
String dept_name=intent.getDept_name();
String attitude=intent.getAttitude();
//获取用户名称
HttpSession session=request.getSession();
Employee oneEmpInfo=null;
oneEmpInfo=(Employee)session.getAttribute("oneEmpInfo");
String emp_name=oneEmpInfo.getEmp_name();
// String emp_name="2321312";
//创建Emp_trainForm对象
//Emp_trainForm newIntentForm=new Emp_trainForm();
//newIntentForm.setDept_name(dept_name);
//newIntentForm.setAttitude(attitude);
// 测试
//boolean OKOrNot=true;
OKOrNot = serviceFactory.getTrainIntentService().submitTrainIntent(emp_name, dept_name, attitude);
//跳转
if(OKOrNot){
request.setAttribute("dest", "TrainAction.do?method=displayAllTrainInfo");
return mapping.findForward("jump");
//return mapping.findForward("YXSuccess");
}else{
request.setAttribute("error", "提交培训意向信息失败!");
request.setAttribute("back2", "TrainAction.do?method=displayAllTrainInfo");
return mapping.findForward("ue");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("error", "提交培训意向信息失败!");
request.setAttribute("back2", "TrainAction.do?method=displayAllTrainInfo");
return mapping.findForward("ue");
}
}
// 显示所有意向信息
public ActionForward displayAllTrainIntents(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
List<Emp_train> intents=serviceFactory.getTrainIntentService().displayAllIntents();
request.setAttribute("intents", intents);
return mapping.findForward("YXadmin");
}
public void setServiceFactory(ServiceFactory serviceFactory) {
this.serviceFactory = serviceFactory;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -