package com.student.action;
import org.apache.struts.action.*;
import org.apache.struts.actions.*;
import javax.servlet.http.*;
import com.student.entity.Student;
import com.student.service.StudentService;
import java.util.Collection;
import java.sql.Date;
public class StudentAction extends DispatchAction
{
private StudentService service = new StudentService();
public ActionForward find(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ActionForward forward = mapping.findForward("list");
try
{
Collection students = service.find();
request.setAttribute("students", students);
}catch(Exception e)
{
e.printStackTrace();
forward = mapping.findForward("error");
}
return forward;
}
public ActionForward tomodify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ActionForward forward = mapping.findForward("modify");
try
{
String id = request.getParameter("id");
Student student = service.findById(Integer.parseInt(id));
request.setAttribute("student", student);
}catch(Exception e)
{
e.printStackTrace();
forward = mapping.findForward("error");
}
return forward;
}
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ActionForward forward = mapping.findForward("tolist");
try
{
String name = request.getParameter("name");
String birthday = request.getParameter("birthday");
Student student = new Student();
student.setName(name);
student.setBirthday(Date.valueOf(birthday));
service.add(student);
}catch(Exception e)
{
e.printStackTrace();
forward = mapping.findForward("error");
}
return forward;
}
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ActionForward forward = mapping.findForward("tolist");
try
{
String name = request.getParameter("name");
String birthday = request.getParameter("birthday");
int id = Integer.parseInt(request.getParameter("id"));
Student student = new Student();
student.setId(id);
student.setName(name);
student.setBirthday(Date.valueOf(birthday));
service.modify(student);
}catch(Exception e)
{
e.printStackTrace();
forward = mapping.findForward("error");
}
return forward;
}
public ActionForward remove(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ActionForward forward = mapping.findForward("tolist");
try
{
String id = request.getParameter("id");
service.remove(Integer.parseInt(id));
}catch(Exception e)
{
e.printStackTrace();
forward = mapping.findForward("error");
}
return forward;
}
public ActionForward toadd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
return mapping.findForward("add");
}
}
简易学生管理系统
需积分: 10 50 浏览量
2008-07-17
22:53:17
上传
评论
收藏 24KB ZIP 举报
apple90
- 粉丝: 439
- 资源: 1
最新资源
- 基于Qt及OpenCv设计了一个视觉检测系统,实现了米粒的计数、缺陷分析功能+源码+文档说明+效果图
- 基于STM32F1和TB6612芯片的电机驱动板,可以驱动两个电机正反转,具有比L298N更小的体积源码+文档说明
- 基于Javascript的CNN卷积交互式播放器设计源码
- 基于Layui的树表格(treeGrid)前端设计源码
- 基于Vue框架的Node+Vue茶叶商城设计源码
- 基于HTML的响应式网站设计源码
- 基于Python的CNN医学图像分割设计源码
- jjcbbdnfiapchhkemifphepfgilhdokf_4.5.6_chrome.zzzmh.cn.crx
- Screenshot_20240418_234552.jpg
- Screenshot_20240418_234558.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈