📄 select.java
字号:
/* * Select.java * * Created on 2006年5月31日, 下午10:00 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package enova.web.struts.action;import javax.servlet.http.*;import org.apache.struts.action.*;import enova.service.*;import enova.pojo.*;import enova.util.Const;/** * * @author vlinux */public class Select extends org.apache.struts.actions.DispatchAction { public ActionForward department(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ DepartmentService ds = (DepartmentService)ServiceFactory.makeService("DepartmentService"); request.setAttribute("departments",ds.getAll()); }catch(StoreException se){ request.setAttribute(Const.MESSAGES,"数据库出错"); return mapping.findForward(Const.STORE_EXCEPTION); } return mapping.findForward(Const.DEPARTMENT); } public ActionForward special(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ String departmentId = request.getParameter("departmentId"); if( departmentId==null || departmentId.length()<=0 ){ DepartmentService ds = (DepartmentService)ServiceFactory.makeService("DepartmentService"); request.setAttribute("departments",ds.getAll()); }else{ Integer deptId = new Integer(Integer.parseInt(departmentId)); SpecialService ss = (SpecialService)ServiceFactory.makeService("SpecialService"); request.setAttribute("specials",ss.getByDepartmentId(deptId)); } }catch(StoreException se){ request.setAttribute(Const.MESSAGES,"数据库出错"); return mapping.findForward(Const.STORE_EXCEPTION); } return mapping.findForward(Const.SPECIAL); } public ActionForward teacher(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ String username = request.getParameter("username"); String name = request.getParameter("name"); TeacherService ts = (TeacherService)ServiceFactory.makeService("TeacherService"); java.util.List list = null; if( (username!=null&&username.length()>0) && (name!=null&&name.length()>0)) list = ts.getByNameAndUsername(name,username); else if(username!=null && username.length()>0) list = ts.getByUsername(username); else list = ts.getByName(name); request.setAttribute("teachers",list); }catch(StoreException se){ request.setAttribute(Const.MESSAGES,"数据库出错"); return mapping.findForward(Const.STORE_EXCEPTION); } return mapping.findForward(Const.TEACHER); } public ActionForward classx(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ String departmentId = request.getParameter("departmentId"); String specialId = request.getParameter("specialId"); if( departmentId==null || departmentId.length()<=0 ){ DepartmentService ds = (DepartmentService)ServiceFactory.makeService("DepartmentService"); request.setAttribute("departments",ds.getAll()); }else if( specialId==null || specialId.length()<=0 ){ Integer deptId = new Integer(Integer.parseInt(departmentId)); SpecialService ss = (SpecialService)ServiceFactory.makeService("SpecialService"); request.setAttribute("specials",ss.getByDepartmentId(deptId)); }else{ Integer spelId = new Integer(Integer.parseInt(specialId)); ClassService cs = (ClassService)ServiceFactory.makeService("ClassService"); request.setAttribute("classes",cs.getBySpecialId(spelId)); } }catch(StoreException se){ request.setAttribute(Const.MESSAGES,"数据库出错"); return mapping.findForward(Const.STORE_EXCEPTION); } return mapping.findForward(Const.CLASS); } public ActionForward course(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ Integer year; try{ year = new Integer(Integer.parseInt(request.getParameter("year"))); }catch(Exception e){ year = null; } String term = request.getParameter("term"); CourseService cs = (CourseService)ServiceFactory.makeService("CourseService"); java.util.List list = null; if( year!=null && term!=null && term.length()>0 ) list = cs.getByYearAndTerm(year,term); else if( year!=null ) list = cs.getByYear(year); else{ list = cs.getByYear(null); } request.setAttribute("courses",list); }catch(StoreException se){ request.setAttribute(Const.MESSAGES,"数据库出错"); return mapping.findForward(Const.STORE_EXCEPTION); } return mapping.findForward(Const.COURSE); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -