📄 queryplanaction.java
字号:
package com.cattsoft.plan.action;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
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 org.apache.struts.action.DynaActionForm;
import com.cattsoft.DAOFactory.DAOFactory;
import com.cattsoft.plan.daoImpl.PlanInfo;
import com.cattsoft.vo.Plan;
import com.cattsoft.vo.Task;
public class QueryPlanAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
String emId = (String) session.getAttribute("username");
List<Task> list1 = null;
try {
list1 = DAOFactory.getPlanInstance().queryTask(emId);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
}
request.setAttribute("list1", list1);
DynaActionForm dyform = (DynaActionForm) form;
// 得到计划名称
String pName = (String) dyform.get("p_name");
// 得到计划所属任务
int tId = 0;
if (dyform.get("t_id") != null) {
tId = (Integer) dyform.get("t_id");
}
// 得到计划开始时间和结束时间
String pStime = (String) dyform.get("p_stime");
String pStime2 = (String) dyform.get("p_stime2");
String pEtime = (String) dyform.get("p_etime");
String pEtime2 = (String) dyform.get("p_etime2");
// 得到反馈状态值
String fState = (String) dyform.get("f_state");
// 根据得到的值去查询plan表
List<Plan> list = new ArrayList<Plan>();
try {
list = DAOFactory.getPlanInstance().queryLike(emId, pName, tId,
pStime, pStime2, pEtime, pEtime2, fState);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
if (list.size() == 0) {
request.setAttribute("error", "找不到您要的计划信息");
return mapping.findForward("queryPlanFailed");
} else {
request.setAttribute("list", list);
return mapping.findForward("queryPlanSuccessed");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -