📄 adminaction.java
字号:
package limq.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;
import org.apache.struts.validator.*;
import limq.hibernate.vo.*;
import java.util.*;
public class AdminAction extends BaseDispatchAction {
public ActionForward newStudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Department[] deps = super.getAdminService().getAllDepartment();
request.setAttribute("deps", deps);
return mapping.findForward("success");
}
public ActionForward insertStudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String username = (String) ((DynaValidatorForm) form).get("username");
String password = (String) ((DynaValidatorForm) form).get("password");
String address = (String) ((DynaValidatorForm) form).get("address");
String email =(String) ((DynaValidatorForm) form).get("email");
Integer phone = Integer.valueOf((String) ((DynaValidatorForm) form).get("phone"));
Integer dep_id = Integer.valueOf((String) ((DynaValidatorForm) form).get("department"));
super.getAdminService().insertStudent(username, password, address,
email, phone, dep_id);
return mapping.findForward("success");
}
public ActionForward viewAllStudents(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Students[] stus = super.getAdminService().getAllStudents();
request.setAttribute("students", stus);
return mapping.findForward("success");
}
public ActionForward removeStudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Integer stu_id = Integer.valueOf(request.getParameter("stu_id"));
super.getAdminService().removeStudent(stu_id);
return mapping.findForward("success");
}
public ActionForward changeStudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Department[] deps = super.getAdminService().getAllDepartment();
request.setAttribute("deps", deps);
return mapping.findForward("success");
}
public ActionForward upstudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer stu_id = Integer.valueOf(request.getParameter("stu_id"));
Students stu = super.getAdminService().getStudentsById(stu_id);
String password = (String) ((DynaValidatorForm) form).get("password");
String address = (String) ((DynaValidatorForm) form).get("address");
String email = (String) ((DynaValidatorForm) form).get("email");
String phone = (String) ((DynaValidatorForm) form).get("phone");
Double score = Double.valueOf((String) ((DynaValidatorForm) form)
.get("score"));
Integer dep_id = Integer.valueOf((String) ((DynaValidatorForm) form)
.get("dep_id"));
Department department = super.getAdminService().getDepartmentById(
dep_id);
Contact con = stu.getContact();
con.setAddress(address);
con.setEmail(email);
con.setPhone(Integer.valueOf(phone));
stu.setPassword(password);
stu.setScore(score);
stu.setDepartment(department);
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -