add:<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="entity.*,java.util.*,java.text.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>员工管理</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="css/style.css" /> </head> <body> <div id="wrap"> <div id="top_content"> <div id="header"> <div id="rightheader"> <p> <% SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); %> <%=sdf.format(new Date())%><br /> </p> </div> <div id="topheader"> <h1 id="title"> <a href="#">Main</a> </h1> </div> <div id="navigation"></div> </div> <div id="content"> <p id="whereami"></p> <h1>添加员工</h1> <form action="add.do" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="form_table"> <tr> <td valign="middle" align="right">姓名:</td> <td valign="middle" align="left"><input type="text" class="inputgri" name="name" /></td> </tr> <tr> <td valign="middle" align="right">薪资:</td> <td valign="middle" align="left"><input type="text" class="inputgri" name="salary" /></td> </tr> <tr> <td valign="middle" align="right">年龄:</td> <td valign="middle" align="left"><input type="text" class="inputgri" name="age" /></td> </tr> </table> <p> <input type="submit" class="button" value="提交" /> </p> </form> </div> </div> <div id="footer"> <div id="footer_bg">[email protected]</div> </div> </div> </body> </html>
update: <%@page import="dao.EmployeeDAO"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="entity.*,java.util.*,java.text.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>员工管理</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="css/style.css" /> </head> <body> <div id="wrap"> <div id="top_content"> <div id="header"> <div id="rightheader"> <p> <% SimpleDateFormat sdf = new SimpleDateFormat(); %> <%=sdf.format(new Date())%><br /> </p> </div> <div id="topheader"> <h1 id="title"> <a href="#">Main</a> </h1> </div> <div id="navigation"></div> </div> <div id="content"> <p id="whereami"></p> <h1>修改员工</h1> <% Employee e = (Employee) request.getAttribute("e"); %> <form action="modify.do" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="form_table"> <tr> <td valign="middle" align="right">id:</td> <td valign="middle" align="left"><%=e.getId()%>></td> </tr> <tr> <td valign="middle" align="right">name:</td> <td valign="middle" align="left"><input type="text" class="inputgri" name="name" value="<%=e.getName()%>" /></td> </tr> <tr> <td valign="middle" align="right">salary:</td> <td valign="middle" align="left"><input type="text" class="inputgri" name="salary" value="<%=e.getSalary()%>" /></td> </tr> <tr> <td valign="middle" align="right">age:</td> <td valign="middle" align="left"><input type="text" class="inputgri" name="age" value="<%=e.getAge()%>" /></td> </tr> </table> <p> <input type="submit" class="button" value="提交" /> </p> <input type="hidden" name="id" value="<%=e.getId()%>" /> </form> </div> </div> <div id="footer"> <div id="footer_bg">[email protected]</div> </div> </div> </body> </html> list:
<%@page import="dao.EmployeeDAO"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="entity.*,java.util.*,java.text.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>员工管理</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="css/style.css" /> </head> <body> <div id="wrap"> <div id="top_content"> <div id="header"> <div id="rightheader"> <p> <% SimpleDateFormat sdf = new SimpleDateFormat(); %> <%=sdf.format(new Date())%> <br /> </p> </div> <div id="topheader"> <h1 id="title"> <a href="#">main</a> </h1> </div> <div id="navigation"></div> </div> <div id="content"> <p id="whereami"></p> <h1>欢迎</h1> <table class="table"> <tr class="table_header"> <td>ID</td> <td>姓名</td> <td>薪资</td> <td>年龄</td> <td>操作</td> </tr> <% List<Employee> employees = (List<Employee>) request.getAttribute("employees"); for (int i = 0; i < employees.size(); i++) { Employee e = employees.get(i); %> <tr class="row<%=i % 2 + 1%>>"> <td><%=e.getId()%></td> <td><%=e.getName()%></td> <td><%=e.getSalary()%></td> <td><%=e.getAge()%></td> <td><a href="del.do?id=<%=e.getId()%>">删除</a> <a href="load.do?id=<%=e.getId()%>">修改</a></td> </tr> <% } %> </table> <p> <input type="button" class="button" value="添加员工" onclick="location=‘addEmp.jsp‘" /> </p> </div> </div> <div id="footer"> <div id="footer_bg">[email protected]</div> </div> </div> </body> </html>web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <servlet> <servlet-name>actionServlet</servlet-name> <servlet-class>web.ActionServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>actionServlet</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>
时间: 2024-10-12 15:06:00