├── webJava ├── .settings │ ├── org.eclipse.wst.jsdt.ui.superType.name │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.wst.ws.service.policy.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.common.component │ ├── .jsdtscope │ └── org.eclipse.jdt.core.prefs ├── WebContent │ ├── META-INF │ │ └── MANIFEST.MF │ ├── css │ │ ├── index.css │ │ ├── xinxi.css │ │ └── zhuce.css │ ├── images │ │ └── post2.jpg │ ├── lib │ │ └── mysql-connector-java-5.1.8.jar │ ├── html │ │ ├── index.html │ │ ├── zhuce.jsp │ │ ├── addEmp.jsp │ │ ├── updateEmp.jsp │ │ └── listEmp.jsp │ ├── index.jsp │ └── WEB-INF │ │ └── web.xml ├── src │ ├── com │ │ └── tedu │ │ │ ├── Test │ │ │ ├── Test01.java │ │ │ └── TestCase.java │ │ │ ├── dao │ │ │ ├── EmpDao.java │ │ │ └── UserDao.java │ │ │ ├── utils │ │ │ ├── DBTools.java │ │ │ └── UUIDUtil.java │ │ │ ├── web │ │ │ └── EmpServlet.java │ │ │ └── entity │ │ │ ├── Emp.java │ │ │ └── userInfo.java │ └── db.properties ├── build │ └── classes │ │ ├── com │ │ └── tedu │ │ │ ├── Test │ │ │ ├── Test01.class │ │ │ └── TestCase.class │ │ │ ├── dao │ │ │ ├── EmpDao.class │ │ │ └── UserDao.class │ │ │ ├── entity │ │ │ ├── Emp.class │ │ │ └── userInfo.class │ │ │ ├── utils │ │ │ ├── DBTools.class │ │ │ └── UUIDUtil.class │ │ │ └── web │ │ │ └── EmpServlet.class │ │ └── db.properties ├── WebRoot │ └── WEB-INF │ │ ├── classes │ │ └── com │ │ │ └── tedu │ │ │ ├── Test │ │ │ ├── Test01.class │ │ │ └── TestCase.class │ │ │ ├── dao │ │ │ └── EmpDao.class │ │ │ ├── entity │ │ │ └── Emp.class │ │ │ └── utils │ │ │ └── DBTools.class │ │ └── web.xml ├── db.properties ├── .mymetadata ├── (2).classpath ├── .classpath └── .project └── README.md /webJava/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /webJava/WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /webJava/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /webJava/WebContent/css/index.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebContent/css/index.css -------------------------------------------------------------------------------- /webJava/WebContent/css/xinxi.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebContent/css/xinxi.css -------------------------------------------------------------------------------- /webJava/WebContent/css/zhuce.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebContent/css/zhuce.css -------------------------------------------------------------------------------- /webJava/WebContent/images/post2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebContent/images/post2.jpg -------------------------------------------------------------------------------- /webJava/src/com/tedu/Test/Test01.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/src/com/tedu/Test/Test01.java -------------------------------------------------------------------------------- /webJava/src/com/tedu/dao/EmpDao.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/src/com/tedu/dao/EmpDao.java -------------------------------------------------------------------------------- /webJava/src/com/tedu/Test/TestCase.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/src/com/tedu/Test/TestCase.java -------------------------------------------------------------------------------- /webJava/src/com/tedu/utils/DBTools.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/src/com/tedu/utils/DBTools.java -------------------------------------------------------------------------------- /webJava/src/com/tedu/web/EmpServlet.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/src/com/tedu/web/EmpServlet.java -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/Test/Test01.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/Test/Test01.class -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/dao/EmpDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/dao/EmpDao.class -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/dao/UserDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/dao/UserDao.class -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/entity/Emp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/entity/Emp.class -------------------------------------------------------------------------------- /webJava/.settings/org.eclipse.wst.ws.service.policy.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.wst.ws.service.policy.projectEnabled=false 3 | -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/Test/TestCase.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/Test/TestCase.class -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/utils/DBTools.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/utils/DBTools.class -------------------------------------------------------------------------------- /webJava/WebContent/lib/mysql-connector-java-5.1.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebContent/lib/mysql-connector-java-5.1.8.jar -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/entity/userInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/entity/userInfo.class -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/utils/UUIDUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/utils/UUIDUtil.class -------------------------------------------------------------------------------- /webJava/build/classes/com/tedu/web/EmpServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/build/classes/com/tedu/web/EmpServlet.class -------------------------------------------------------------------------------- /webJava/WebRoot/WEB-INF/classes/com/tedu/Test/Test01.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebRoot/WEB-INF/classes/com/tedu/Test/Test01.class -------------------------------------------------------------------------------- /webJava/WebRoot/WEB-INF/classes/com/tedu/dao/EmpDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebRoot/WEB-INF/classes/com/tedu/dao/EmpDao.class -------------------------------------------------------------------------------- /webJava/WebRoot/WEB-INF/classes/com/tedu/entity/Emp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebRoot/WEB-INF/classes/com/tedu/entity/Emp.class -------------------------------------------------------------------------------- /webJava/WebRoot/WEB-INF/classes/com/tedu/Test/TestCase.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebRoot/WEB-INF/classes/com/tedu/Test/TestCase.class -------------------------------------------------------------------------------- /webJava/WebRoot/WEB-INF/classes/com/tedu/utils/DBTools.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yehuimmd/javaWeb/HEAD/webJava/WebRoot/WEB-INF/classes/com/tedu/utils/DBTools.class -------------------------------------------------------------------------------- /webJava/db.properties: -------------------------------------------------------------------------------- 1 | #?? 2 | driverClass=com.mysql.jdbc.Driver 3 | url=jdbc\:mysql\://localhost\:3306/test?useUnicode\=true&charestEncoding\=utf-8 4 | user=root 5 | password=123456 6 | 7 | -------------------------------------------------------------------------------- /webJava/src/db.properties: -------------------------------------------------------------------------------- 1 | #?? 2 | driverClass=com.mysql.jdbc.Driver 3 | url=jdbc\:mysql\://localhost\:3306/test?useUnicode\=true&charestEncoding\=utf-8 4 | user=root 5 | password=123456 6 | 7 | -------------------------------------------------------------------------------- /webJava/build/classes/db.properties: -------------------------------------------------------------------------------- 1 | #?? 2 | driverClass=com.mysql.jdbc.Driver 3 | url=jdbc\:mysql\://localhost\:3306/test?useUnicode\=true&charestEncoding\=utf-8 4 | user=root 5 | password=123456 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # javaWeb 2 | javaWeb项目之简单的员工管理系统 3 | 4 | #### 项目说明 5 | 6 | 这是一个使用到Java及web前端相关技术的小项目,用到的技术有HTML、css、java、jsp,jdbc,用到的开发工具是myeclipse,数据库MySQL等。 7 | 8 | #### 实现的功能 9 | 10 | - 员工登录 11 | - 员工注册 12 | - 员工信息的录入 13 | - 员工信息的增删改查 14 | -------------------------------------------------------------------------------- /webJava/.mymetadata: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /webJava/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /webJava/WebRoot/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | index.jsp 9 | 10 | 11 | -------------------------------------------------------------------------------- /webJava/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /webJava/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /webJava/(2).classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /webJava/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /webJava/WebContent/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 登录 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /webJava/WebContent/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 | %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | My JSP 'index.jsp' starting page 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | This is my JSP page.
25 | 26 | 27 | -------------------------------------------------------------------------------- /webJava/WebContent/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Emp 4 | 5 | index.html 6 | index.htm 7 | index.jsp 8 | default.html 9 | default.htm 10 | default.jsp 11 | 12 | 13 | 14 | empServlet 15 | com.tedu.web.EmpServlet 16 | 17 | 18 | 19 | 20 | empServlet 21 | *.do 22 | 23 | 24 | -------------------------------------------------------------------------------- /webJava/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /webJava/WebContent/html/zhuce.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" 2 | pageEncoding="utf-8"%> 3 | 4 | 5 | 6 | 7 | 注册 8 | 9 | 10 | 11 | 12 |
13 |

注册

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | -------------------------------------------------------------------------------- /webJava/src/com/tedu/entity/Emp.java: -------------------------------------------------------------------------------- 1 | package com.tedu.entity; 2 | 3 | public class Emp { 4 | private String id; 5 | private String name; 6 | private String age; 7 | private String salary; 8 | 9 | 10 | public String getId() { 11 | return id; 12 | } 13 | 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | 30 | public String getAge() { 31 | return age; 32 | } 33 | 34 | 35 | public void setAge(String age) { 36 | this.age = age; 37 | } 38 | 39 | 40 | public String getSalary() { 41 | return salary; 42 | } 43 | 44 | 45 | public void setSalary(String salary) { 46 | this.salary = salary; 47 | } 48 | 49 | 50 | @Override 51 | public String toString() { 52 | return "Emp [age=" + age + ", id=" + id + ", name=" + name 53 | + ", salary=" + salary + "]"; 54 | } 55 | 56 | 57 | public static void main(String[] args) { 58 | // TODO Auto-generated method stub 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /webJava/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Emp 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.wst.common.project.facet.core.nature 33 | org.eclipse.jdt.core.javanature 34 | org.eclipse.wst.jsdt.core.jsNature 35 | 36 | 37 | -------------------------------------------------------------------------------- /webJava/src/com/tedu/entity/userInfo.java: -------------------------------------------------------------------------------- 1 | package com.tedu.entity; 2 | 3 | public class userInfo { 4 | private String id; 5 | private String user; 6 | private String password; 7 | private String phone; 8 | private String identity; 9 | 10 | 11 | @Override 12 | public String toString() { 13 | return "userInfo [id=" + id + ", user=" + user + ", password=" 14 | + password + ", phone=" + phone + ", identity=" + identity 15 | + "]"; 16 | } 17 | 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | 24 | public void setId(String id) { 25 | this.id = id; 26 | } 27 | 28 | 29 | public String getUser() { 30 | return user; 31 | } 32 | 33 | 34 | public void setUser(String user) { 35 | this.user = user; 36 | } 37 | 38 | 39 | public String getPassword() { 40 | return password; 41 | } 42 | 43 | 44 | public void setPassword(String password) { 45 | this.password = password; 46 | } 47 | 48 | 49 | public String getPhone() { 50 | return phone; 51 | } 52 | 53 | 54 | public void setPhone(String phone) { 55 | this.phone = phone; 56 | } 57 | 58 | 59 | public String getIdentity() { 60 | return identity; 61 | } 62 | 63 | 64 | public void setIdentity(String identity) { 65 | this.identity = identity; 66 | } 67 | 68 | 69 | public static void main(String[] args) { 70 | // TODO Auto-generated method stub 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /webJava/WebContent/html/addEmp.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" 2 | pageEncoding="utf-8"%> 3 | 4 | 5 | 6 | 7 | 新增员工 8 | 79 | 80 | 81 | 82 | 83 |
84 |

添加员工

85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |
姓名:
薪水:
年龄:
99 | 100 |
101 | 102 | 103 | -------------------------------------------------------------------------------- /webJava/src/com/tedu/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.tedu.dao; 2 | 3 | import java.sql.Connection; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import com.tedu.entity.Emp; 11 | import com.tedu.entity.userInfo; 12 | import com.tedu.utils.DBTools; 13 | 14 | public class UserDao { 15 | 16 | public static List findAll(String sql){ 17 | List list = new ArrayList(); 18 | Connection conn = null; 19 | try { 20 | conn = DBTools.getConnection(); 21 | Statement st = conn.createStatement(); 22 | ResultSet set = st.executeQuery(sql); 23 | while(set.next()){ 24 | userInfo user = new userInfo(); 25 | user.setId(set.getString("id")); 26 | user.setUser(set.getString("user")); 27 | user.setPassword(set.getString("password")); 28 | user.setPhone(set.getString("phone")); 29 | user.setIdentity(set.getString("identity")); 30 | list.add(user); 31 | } 32 | if(list.size()==0){ 33 | return null; 34 | } 35 | } catch (SQLException e) { 36 | // TODO Auto-generated catch block 37 | e.printStackTrace(); 38 | }finally{ 39 | DBTools.close(conn); 40 | } 41 | return list; 42 | } 43 | 44 | 45 | public static userInfo findByName(String name){ 46 | userInfo user = new userInfo(); 47 | Connection conn = null; 48 | String sql = "select * from userinfo where user='"+name+"'"; 49 | try { 50 | conn = DBTools.getConnection(); 51 | Statement statement = conn.createStatement(); 52 | ResultSet set = statement.executeQuery(sql); 53 | if(set.next()==false){ 54 | return null; 55 | }else{ 56 | //userInfo user = new userInfo(); 57 | user.setId(set.getString("id")); 58 | user.setUser(set.getString("user")); 59 | user.setPassword(set.getString("password")); 60 | user.setPhone(set.getString("phone")); 61 | user.setIdentity(set.getString("identity")); 62 | //list.add(user); 63 | } 64 | } catch (SQLException e) { 65 | // TODO Auto-generated catch block 66 | e.printStackTrace(); 67 | }finally{ 68 | DBTools.close(conn); 69 | } 70 | return user; 71 | } 72 | 73 | public static void addUser(userInfo user){ 74 | StringBuffer sql = new 75 | StringBuffer("insert into userinfo(id, user, password, identity, phone) values("); 76 | sql.append("'").append(user.getId()).append("',"); 77 | sql.append("'").append(user.getUser()).append("',"); 78 | sql.append("'").append(user.getPassword()).append("',"); 79 | sql.append("'").append(user.getIdentity()).append("',"); 80 | sql.append("'").append(user.getPhone()).append("')"); 81 | Connection conn = null; 82 | try { 83 | conn = DBTools.getConnection(); 84 | Statement statement = conn.createStatement(); 85 | statement.executeUpdate(sql.toString()); 86 | //statement.executeUpdate(sql.toString()); 87 | } catch (SQLException e) { 88 | // TODO Auto-generated catch block 89 | e.printStackTrace(); 90 | }finally{ 91 | DBTools.close(conn); 92 | } 93 | //System.out.println(sql.toString()); 94 | } 95 | public static void main(String[] args) { 96 | // TODO Auto-generated method stub 97 | 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /webJava/WebContent/html/updateEmp.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" 2 | pageEncoding="utf-8"%> 3 | <%@ page import="com.tedu.entity.* "%> 4 | 5 | 6 | 7 | 8 | 修改员工 9 | 80 | 81 | 82 | 83 | 84 | <% 85 | Emp emp = (Emp)request.getAttribute("emp"); 86 | 87 | %> 88 |
89 |

修改员工

90 | 91 | 92 | 93 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |
ID:
姓名:
薪水:
年龄:
109 | 110 | 111 |
112 | 113 | -------------------------------------------------------------------------------- /webJava/WebContent/html/listEmp.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" 2 | pageEncoding="utf-8"%> 3 | <%@ page import="com.tedu.entity.*, java.util.*" %> 4 | 5 | 6 | 7 | 8 | 员工信息 9 | 10 | 83 | 84 | 85 | 86 | 87 |
88 |

欢迎

89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | <% 98 | List emps = (List)request.getAttribute("emps"); 99 | if(null == emps){ 100 | %> 101 | 102 | 103 | 104 | <% 105 | }else{ 106 | for(int i = 0; i < emps.size(); i++){ 107 | Emp emp = emps.get(i); 108 | %> 109 | 110 | 111 | 112 | 113 | 114 | 119 | <% 120 | } 121 | } 122 | %> 123 |
ID姓名年龄工资操作
没有数据
<%=emp.getId() %><%=emp.getName() %><%=emp.getAge() %><%=emp.getSalary() %> 115 | 删除 117 |  修改 118 |
124 | 126 |
127 | 128 | -------------------------------------------------------------------------------- /webJava/src/com/tedu/utils/UUIDUtil.java: -------------------------------------------------------------------------------- 1 | package com.tedu.utils; 2 | 3 | import java.net.InetAddress; 4 | import java.util.UUID; 5 | 6 | /** 7 | *
  8 |  * UUID 辅助工具.
  9 |  * Description: 
 10 |  *    
 11 |  * Author: zhouguangyong@iyooc.cn
 12 |  * Date: 2014-01-01 上午10:00:01
 13 |  * Copyright: Copyright ©2006-2015 iyooc.cn Technology Co., Ltd. All rights reserved.
 14 |  * Changelog:
 15 |  *   Ver   Date                  Author              Detail
 16 |  *   ----------------------------------------------------------------------
 17 |  *   1.0   2014-01-01 10:00:01   zhouguangyong@iyooc.cn
 18 |  *         new file.
 19 |  * 
20 | */ 21 | public abstract class UUIDUtil { 22 | 23 | protected static final String IP; 24 | 25 | protected static final String JVM; 26 | 27 | protected static short COUNTER = (short) 0; 28 | 29 | protected static final Object _lock = new Object(); 30 | 31 | static { 32 | int ip; 33 | try { 34 | // System.out.println(InetAddress.getLocalHost().getHostAddress()); 35 | InetAddress ia = InetAddress.getLocalHost(); 36 | // String _ip = ia.getHostAddress(); 37 | ip = toInt(ia.getAddress()); 38 | } catch (Exception e) { 39 | ip = 0; 40 | } 41 | String _ip = Integer.toHexString(ip); 42 | StringBuffer sb = new StringBuffer("00000000"); 43 | sb.replace(8 - _ip.length(), 8, _ip); 44 | IP = sb.toString(); 45 | 46 | int jvm = (int) (System.currentTimeMillis() >>> 8); 47 | String _jvm = Integer.toHexString(jvm); 48 | StringBuffer jvmSb = new StringBuffer("00000000"); 49 | jvmSb.replace(8 - _jvm.length(), 8, _jvm); 50 | JVM = jvmSb.toString(); 51 | } 52 | 53 | /** 54 | * 受保护的构造方法, 防止外部构建对象实例. 55 | */ 56 | protected UUIDUtil() { 57 | super(); 58 | } 59 | 60 | /** 61 | * 二进制转换为Int值. 62 | * 63 | * @param bytes 64 | * @return int 65 | */ 66 | public static int toInt(byte[] bytes) { 67 | int result = 0; 68 | for (int i = 0; i < 4; i++) { 69 | result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i]; 70 | } 71 | return result; 72 | } 73 | 74 | /** 75 | * Unique in a millisecond for this JVM instance (unless there are > 76 | * Short.MAX_VALUE instances created in a millisecond) 77 | */ 78 | protected static short getCount() { 79 | synchronized (_lock) { 80 | if (COUNTER < 0) { 81 | COUNTER = 0; 82 | } 83 | return COUNTER++; 84 | } 85 | } 86 | 87 | /** 88 | * 生成数据库记录PK(模拟Hibernate中的UUID策略). 89 | * 90 | * @return String 91 | */ 92 | public static String getUuid() { 93 | StringBuffer sb = new StringBuffer(36); 94 | sb.append(IP).append(JVM); 95 | 96 | short hitime = (short) (System.currentTimeMillis() >>> 32); 97 | String _hitime = Integer.toHexString(hitime); 98 | StringBuffer hitimeSb = new StringBuffer("0000"); 99 | hitimeSb.replace(4 - _hitime.length(), 4, _hitime); 100 | sb.append(hitimeSb); 101 | 102 | int lotime = (int) System.currentTimeMillis(); 103 | String _lotime = Integer.toHexString(lotime); 104 | StringBuffer lotimeSb = new StringBuffer("00000000"); 105 | lotimeSb.replace(8 - _lotime.length(), 8, _lotime); 106 | sb.append(lotimeSb); 107 | 108 | short count = getCount(); 109 | String _count = Integer.toHexString(count); 110 | StringBuffer countSb = new StringBuffer("0000"); 111 | countSb.replace(4 - _count.length(), 4, _count); 112 | sb.append(countSb); 113 | 114 | return sb.toString().toUpperCase(); 115 | } 116 | 117 | public static String getUuid32(){ 118 | return UUID.randomUUID().toString().replace("-", ""); 119 | } 120 | } 121 | --------------------------------------------------------------------------------