三层架构
- 持久层--Mybatis
- 表现层--Servlet + Jsp
- Spring--管理对象、切面处理
基于MVC模式
视图--Jsp
模型--JavaBean
-
控制器--Servlet+JavaBean
核心控制器
1、Servlet对象由Web容器管理
2、Service对象由IOC容器管理
- 持久层实现不用创建类,而是通过Mybatis配置文件实现的。
- controller通过注解配置servlet
部门管理
步骤
- 实体类
- Dao接口与Mybatis配置文件
- Service接口与其实现类
- 控制器
- 页面
日志模块
采用AOP切面处理
- applicationContext.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!--Spirng整合Mybatis-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql:///sm?characterEncoding=utf-8"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!--配置后直接使用类型,不用写包的全路径-->
<!--实体类可以用简称-->
<property name="typeAliasesPackage" value="com.alan.entity"></property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.alan.dao"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!--声明式事务-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--通知设置-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="search*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!--织入-->
<aop:config >
<!--切入点设置-->
<aop:pointcut id="txPointcut" expression="execution(* com.alan.service.*.*(..))"></aop:pointcut>
<!--切入点与通知进行关联-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"></aop:advisor>
</aop:config>
<!--启动全局扫描-->
<context:component-scan base-package="com.alan"></context:component-scan>
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans>
- mybatis 相关 xml
- DepartmentDao.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.4//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.alan.dao.DepartmentDao">
<!--这里可以不写全路径,应为在spring中已经配置了-->
<resultMap id="resultMap" type="Department">
<!--主键的话用id标签-->
<id property="id" column="id" javaType="Integer"></id>
<!--其他的用result标签-->
<result property="name" column="name" javaType="String"></result>
<result property="address" column="address" javaType="String"></result>
</resultMap>
<!--设置参数和自增-->
<insert id="insert" parameterType="Department" useGeneratedKeys="true">
insert into department(name,address) values (#{name},#{address})
</insert>
<delete id="delete" parameterType="Integer">
delete from department where id = #{id}
</delete>
<update id="update" parameterType="Department">
update department set name=#{name},address=#{address} where id = #{id}
</update>
<select id="selectById" parameterType="Integer" resultMap="resultMap">
select * from department where id = #{id}
</select>
<select id="selectAll" resultMap="resultMap">
select * from department
</select>
</mapper>
- LogDao.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.4//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.alan.dao.LogDao">
<!--这里可以不写全路径,应为在spring中已经配置了-->
<resultMap id="resultMap" type="Log">
<!--其他的用result标签-->
<result property="oprTime" column="opr_time" javaType="java.util.Date"></result>
<result property="type" column="type" javaType="String"></result>
<result property="operator" column="operator" javaType="String"></result>
<result property="moudle" column="moudle" javaType="String"></result>
<result property="operation" column="operation" javaType="String"></result>
<result property="result" column="result" javaType="String"></result>
</resultMap>
<insert id="insert" parameterType="Log" >
insert into log(opr_time,type,operator,moudle,operation,result)
values(#{oprTime},#{type},#{operator},#{moudle},#{operation},#{result})
</insert>
<select id="selectByType" parameterType="String" resultMap="resultMap">
select * from log where type=#{type} order by opr_time desc
</select>
</mapper>
- SelfDao.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.4//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.alan.dao.SelfDao">
<select id="selectByAccount" parameterType="String" resultMap="com.alan.dao.StaffDao.resultMap">
select * from staff where account=#{account}
</select>
</mapper>
- StaffDao.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.4//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.alan.dao.StaffDao">
<!--这里可以不写全路径,应为在spring中已经配置了-->
<resultMap id="resultMap" type="Staff">
<!--主键的话用id标签-->
<id property="id" column="id" javaType="Integer"></id>
<!--其他的用result标签-->
<result property="account" column="account" javaType="String"></result>
<result property="password" column="password" javaType="String"></result>
<result property="status" column="status" javaType="String"></result>
<result property="did" column="did" javaType="Integer"></result>
<result property="name" column="name" javaType="String"></result>
<result property="sex" column="sex" javaType="String"></result>
<result property="idNumber" column="id_number" javaType="String"></result>
<result property="workTime" column="work_time" javaType="Date"></result>
<result property="leaveTime" column="leave_time" javaType="Date"></result>
<result property="bornDate" column="born_date" javaType="Date"></result>
<result property="info" column="info" javaType="String"></result>
<!--配置多对一关联,通过部门映射表中的select语句进行查询-->
<association property="department" column="did" javaType="Department" select="com.alan.dao.DepartmentDao.selectById" ></association>
</resultMap>
<insert id="insert" parameterType="Staff" useGeneratedKeys="true">
insert into staff(account,password,status,did,name,sex,id_number,work_time,leave_time,born_date,info)
values(#{account},#{password},#{status},#{did},#{name},#{sex},#{idNumber},#{workTime},#{leaveTime},#{bornDate},#{info})
</insert>
<delete id="delete" parameterType="Integer">
delete from staff where id=#{id}
</delete>
<update id="update" parameterType="Staff">
update staff set account=#{account},password=#{password},status=#{status},
did=#{did},name=#{name},sex=#{sex},id_number=#{idNumber},
work_time=#{workTime},leave_time=#{leaveTime},born_date=#{bornDate},info=#{info} where id=#{id}
</update>
<select id="selectById" parameterType="Integer" resultMap="resultMap">
select * from staff where id=#{id}
</select>
<select id="selectAll" resultMap="resultMap">
select * from staff
</select>
</mapper>
- DispatcherServlet 中央控制器
package com.alan.global;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class DispatcherServlet extends GenericServlet {
private ApplicationContext applicationContext ;
public void init() throws ServletException {
applicationContext = new ClassPathXmlApplicationContext("spring.xml");
}
@Override
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
/**
* staff/add.do login.do
* staffController
*/
//或者请求的url路径,将最前面的/截取掉
String path = request.getServletPath().substring(1);
String beanName ;
String methodName;
int index = path.indexOf('/');
//包含反斜杠
if(index != -1){
beanName= path.substring(0,index)+"Controller"; //staffController
methodName = path.substring(index+1,path.indexOf(".do"));
}else {
beanName = "selfController"; //只有特殊的这一个
methodName = path.substring(0,path.indexOf(".do"));
}
System.out.println("path:"+path+",beanName:"+beanName+",methodName"+ methodName);
Object object = applicationContext.getBean(beanName);
try {
Method method = object.getClass().getMethod(methodName, HttpServletRequest.class, HttpServletResponse.class);
method.invoke(object,request,response);
}catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.getTargetException();
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
- 登陆过滤器
package com.alan.global;
import com.alan.entity.Staff;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 登陆过滤器
*/
public class LoginFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) resp;
String path = request.getServletPath();
if(path.toLowerCase().indexOf("login") != -1){
//包含login的url,直接放行。不进行过滤处理
chain.doFilter(request,response);
}else {
Staff staff = (Staff) request.getSession().getAttribute("USER");
if(staff != null){
//session中有员工信息,直接放行,不进行过滤处理
chain.doFilter(request,response);
}else {
//强制跳转回登陆界面
response.sendRedirect(request.getContextPath()+"/toLogin.do");
}
}
}
public void init(FilterConfig config) throws ServletException {
}
}
- AOP切面类
package com.alan.global;
import com.alan.entity.Log;
import com.alan.entity.Staff;
import com.alan.service.LogService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**
* 记录日志的切面类
*/
//@Component泛指各种组件,就是说当我们的类不属于各种归类的时候(不属于@Controller、@Services等的时候),我们就可以使用@Component来标注这个类。
@Component
//aspect切面注解
@Aspect
public class LogAdvice {
@Autowired
private LogService logService;
//配置运行日志,屏蔽掉SelfController,同时屏蔽to开头的例如toAdd等
@After("execution(* com.alan.controller.*.*(..)) &&!execution(* com.alan.controller.SelfController.*(..)) && !execution(* com.alan.controller.*.to*(..))")
public void operationLog(JoinPoint joinPoint){
Log log = new Log();
//模块名称赋值为类名
log.setMoudle(joinPoint.getTarget().getClass().getSimpleName());
//当前操作赋值为方法名
log.setOperation(joinPoint.getSignature().getName());
//当前方法的第一个参数为request
HttpServletRequest request = (HttpServletRequest) joinPoint.getArgs()[0];
Staff staff = (Staff) request.getSession().getAttribute("USER");
//设置操作人
log.setOperator(staff.getAccount());
log.setResult("成功");
logService.addOperationLog(log);
}
//配置系统日志,只有出现异常后进行记录,配置throwing
@AfterThrowing(throwing = "e" ,pointcut = "execution(* com.alan.controller.*.*(..)) && !execution(* com.alan.controller.SelfController.*(..))")
public void systemLog(JoinPoint joinPoint ,Throwable e){
Log log = new Log();
//模块名称赋值为类名
log.setMoudle(joinPoint.getTarget().getClass().getSimpleName());
//当前操作赋值为方法名
log.setOperation(joinPoint.getSignature().getName());
//当前方法的第一个参数为request
HttpServletRequest request = (HttpServletRequest) joinPoint.getArgs()[0];
Staff staff = (Staff) request.getSession().getAttribute("USER");
log.setOperator(staff.getAccount());
//将异常对象的名称传入到LOG中
log.setResult(e.getClass().getSimpleName());
logService.addSystemLog(log);
}
//配置登陆日志
@After("execution(* com.alan.controller.SelfController.login(..))")
public void loginLog(JoinPoint joinPoint){
log(joinPoint);
}
//配置退出日志,采用前置通知
@Before("execution(* com.alan.controller.SelfController.logout(..))")
public void logoutLog(JoinPoint joinPoint){
log(joinPoint);
}
private void log(JoinPoint joinPoint){
Log log = new Log();
//模块名称赋值为类名
log.setMoudle(joinPoint.getTarget().getClass().getSimpleName());
//当前操作赋值为方法名
log.setOperation(joinPoint.getSignature().getName());
//当前方法的第一个参数为request
HttpServletRequest request = (HttpServletRequest) joinPoint.getArgs()[0];
Staff staff = (Staff) request.getSession().getAttribute("USER");
if(staff == null){
log.setOperator(request.getParameter("account"));
log.setResult("失败");
}else {
log.setOperator(staff.getAccount());
log.setResult("成功");
}
logService.addLoginLog(log);
}
}
- DepartmentController
package com.alan.controller;
import com.alan.entity.Department;
import com.alan.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@Controller("departmentController")
public class DepartmentController extends HttpServlet {
@Autowired
private DepartmentService departmentService;
public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Department> list = departmentService.getAll();
// Department department = departmentService.get(1);
request.setAttribute("LIST",list);
request.getRequestDispatcher("../department_list.jsp").forward(request,response);
}
public void toAdd(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
request.getRequestDispatcher("../department_add.jsp").forward(request,response);
}
public void add(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
//从request获取参数值
String name = request.getParameter("name");
String address = request.getParameter("address");
//将值复制给Department对象
Department department = new Department();
department.setName(name);
department.setAddress(address);
//插入表中
departmentService.add(department);
//返回list.do,不需要传值,使用重定向
response.sendRedirect("list.do");
}
public void toEdit(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
String id = request.getParameter("id");
Department department = new Department();
//根据id进行查询
department = departmentService.get(Integer.parseInt(id));
//将Department对象回传到更改页面
request.setAttribute("OBJ",department);
request.getRequestDispatcher("../department_edit.jsp").forward(request,response);
}
public void edit(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
//从request获取参数值
String id = request.getParameter("id");
String name = request.getParameter("name");
String address = request.getParameter("address");
//将值复制给Department对象
Department department = new Department();
department.setName(name);
department.setAddress(address);
department.setId(Integer.parseInt(id));
//插入表中
departmentService.edit(department);
//返回list.do,不需要传值,使用重定向
response.sendRedirect("list.do");
}
public void remove(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
String id = request.getParameter("id");
departmentService.remove(Integer.parseInt(id));
response.sendRedirect("list.do");
}
}
- LogController
package com.alan.controller;
import com.alan.entity.Log;
import com.alan.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@Controller("logController")
public class LogController {
@Autowired
private LogService logService;
public void operationLog(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Log> list = logService.getOperationLog();
request.setAttribute("LIST",list);
request.setAttribute("TYPE","操作");
request.getRequestDispatcher("../log_list.jsp").forward(request,response);
}
public void loginLog(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Log> list = logService.getLoginLog();
request.setAttribute("LIST",list);
request.setAttribute("TYPE","登陆");
request.getRequestDispatcher("../log_list.jsp").forward(request,response);
}
public void systemLog(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Log> list = logService.getSystemLog();
request.setAttribute("LIST",list);
request.setAttribute("TYPE","系统");
request.getRequestDispatcher("../log_list.jsp").forward(request,response);
}
}
- SelfController
package com.alan.controller;
import com.alan.entity.Staff;
import com.alan.service.SelfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Controller("selfController")
public class SelfController {
//依赖注入对象
@Autowired
private SelfService selfService;
//跳转到登陆页面 jsp里面应该是toLogin.do
public void toLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("login.jsp").forward(request,response);
}
//登陆流程 login.do
public void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//从页面获取用户名和密码
String account = request.getParameter("account");
String password = request.getParameter("password");
//用户校验
Staff staff = selfService.login(account,password);
if(staff == null){
//密码错误,重定向到登陆页面。一般一些异常可能使用到重定向。url发生改变。
response.sendRedirect("toLogin.do");
}else {
request.getSession().setAttribute("USER",staff);
response.sendRedirect("main.do");
}
}
//打开主页面 main.do
public void main(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("index.jsp").forward(request,response);
}
//退出 logout.do
public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//将session中的USER置空
request.getSession().setAttribute("USER",null);
response.sendRedirect("toLogin.do");
}
// 显示个人信息 /self/info.do
public void info(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("../info.jsp").forward(request,response);
}
//打开修改密码界面 /self/toChange.do
public void toChangePassword(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("../change_password.jsp").forward(request,response);
}
//修改密码 /self/changePassword.do
public void changePassword(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String password = request.getParameter("password");
String password1 = request.getParameter("password1");
Staff staff = (Staff) request.getSession().getAttribute("USER");
if(!staff.getPassword().equals(password)){
response.sendRedirect("toChangePassword.do");
}else {
selfService.changePassword(staff.getId(),password1);
// response.sendRedirect("../logout.do");
//<script type = "text/javascript">parent.location.href="../logout.do"</script>
response.getWriter().print("<script type = \"text/javascript\">parent.location.href=\"../logout.do\"</script>");
}
}
}
- StaffController
package com.alan.controller;
import com.alan.entity.Department;
import com.alan.entity.Department;
import com.alan.entity.Staff;
import com.alan.service.DepartmentService;
import com.alan.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller("staffController")
public class StaffController {
@Autowired
private StaffService staffService;
@Autowired
private DepartmentService departmentService;
public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Staff> list = staffService.getAll();
request.setAttribute("LIST",list);
request.getRequestDispatcher("../staff_list.jsp").forward(request,response);
}
public void toAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Department> list = departmentService.getAll();
request.setAttribute("DLIST",list);
request.getRequestDispatcher("../staff_add.jsp").forward(request,response);
}
public void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String account = request.getParameter("account");
String name = request.getParameter("name");
String sex = request.getParameter("sex");
String idNumber = request.getParameter("idNumber");
String info =request.getParameter("info");
Date bornDate=null;
try {
bornDate = new SimpleDateFormat("yyyy-MM-dd").parse(request.getParameter("bornDate"));
} catch (ParseException e) {
e.printStackTrace();
}
Integer did = Integer.parseInt(request.getParameter("did"));
Staff staff = new Staff();
staff.setInfo(info);
staff.setBornDate(bornDate);
staff.setIdNumber(idNumber);
staff.setDid(did);
staff.setAccount(account);
staff.setName(name);
staff.setSex(sex);
staffService.add(staff);
response.sendRedirect("list.do");
}
public void toEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//编辑界面需要员工信息和部门信息
Integer id = Integer.parseInt(request.getParameter("id"));
Staff staff = staffService.get(id);
request.setAttribute("OBJ",staff);
List<Department> list = departmentService.getAll();
request.setAttribute("DLIST",list);
request.getRequestDispatcher("../staff_edit.jsp").forward(request,response);
}
public void edit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
String account = request.getParameter("account");
String name = request.getParameter("name");
String sex = request.getParameter("sex");
String idNumber = request.getParameter("idNumber");
String info =request.getParameter("info");
Date bornDate=null;
try {
bornDate = new SimpleDateFormat("yyyy-MM-dd").parse(request.getParameter("bornDate"));
} catch (ParseException e) {
e.printStackTrace();
}
Integer did = Integer.parseInt(request.getParameter("did"));
Staff staff = staffService.get(id);
staff.setInfo(info);
staff.setBornDate(bornDate);
staff.setIdNumber(idNumber);
staff.setDid(did);
staff.setAccount(account);
staff.setName(name);
staff.setSex(sex);
staffService.edit(staff);
response.sendRedirect("list.do");
}
public void remove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
staffService.remove(id);
response.sendRedirect("list.do");
}
public void detail(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
Staff staff = staffService.get(id);
request.setAttribute("OBJ",staff);
request.getRequestDispatcher("../staff_detail.jsp").forward(request,response);
}
}