Java Web实战项目:客户管理管理系统(源代码)

过程分析:

Java Web实战项目:客户管理管理系统

传智播客 崔希凡JavaWeb培训视频day19 客户管理系统

源代码下载

(前端,后端,jar包)

截图:

 

整体结构

源代码

com.tinstu.dao ---->CustomerDao.java

package com.tinstu.dao;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.tinstu.domain.Customer;


import cn.itcast.jdbc.TxQueryRunner;

/**
 * 持久层
 * @author Tin
 *
 */
public class CustomerDao {
	private QueryRunner qr = new TxQueryRunner();
	
	public void add(Customer c) {
		try {
			String sql = "insert into customers values (?,?,?,?,?,?,?)";
			
			Object [] params = {c.getCid(),c.getCname(),c.getGender(),c.getBirthday(),c.getCellphone(),c.getEmail(),c.getDescription() };
			qr.update(sql, params);
		} catch(SQLException e) {
			throw new RuntimeException(e);
		}
		
		
		
	}
	/**
	 * 查询所有
	 * @throws SQLException 
	 * 
	 */
	public List<Customer> findAll() throws SQLException{
	    String sql = "select * from customers";	 
		return qr.query(sql, new BeanListHandler<Customer>(Customer.class));
	}
	/**
	 * 加载kehu
	 * @throws SQLException 
	 */
	public Customer load(String cid) throws SQLException {
		String sql = "select * from customers where cid=?";
		return qr.query(sql, new BeanHandler<Customer>(Customer.class),cid);
	}
	/**
	 * 编辑客户
	 * @param c
	 * @throws SQLException 
	 */
	public void edit(Customer c) throws SQLException {
		String sql = "update customers set cname=?,gender=?,birthday=?,"
				+ "cellphone=?,email=?,description=? where cid=?";
		Object [] params = {c.getCname(),c.getGender(),c.getBirthday(),c.getCellphone(),c.getEmail(),c.getDescription(),c.getCid()};
		qr.update(sql, params);
		
	}
	/**
	 * 删除客户
	 * @throws SQLException 
	 */

	public void dele(String cid) throws SQLException{
		String sql = "delete from customers where cid=?";
		Object params = cid;
		qr.update(sql, params);
		
	}
	/**
	 * 多条件查询
	 * @param criteria
	 * @throws SQLException 
	 */
	public List<Customer> query(Customer criteria) throws SQLException {
		/*
		 * 1.给出sql模板
		 * 2.给出参数
		 * 3.调用query方法,使用接口集处理器 :BeanListHandler
		 */
		// 给出一个sql语句的前半部分
		StringBuilder sql = new StringBuilder("select * from customers where 1=1");
		//判断条件,完成向sql中追加where子句
		//创建一个ArrayList3,用来装载参数值
		List<Object> params = new ArrayList<Object>(); 
		String cname = criteria.getCname();
		if(cname != null && !cname.trim().isEmpty()) {
			sql.append(" and cname like ?");
		    params.add("%"+cname+"%");
		}
		String gender = criteria.getGender();
		if(gender != null && !gender.trim().isEmpty()) {
			sql.append(" and gender=?");
			params.add(gender);
		}
		String cellphone = criteria.getCellphone();
		if(cellphone !=null && !cellphone.trim().isEmpty()) {
			sql.append(" and cellphone=?");
			params.add(cellphone);
		}
		String email = criteria.getEmail();
		if(email !=null && !email.trim().isEmpty()) {
			sql.append(" and email= ?");
			params.add(email);
		}
		//执行query
		return qr.query(sql.toString(), new BeanListHandler<Customer>(Customer.class),params.toArray());
	}
	
/*	
	public void updateBySql(String sql) throws SQLException {
		Connection conn = GetConnetion.getConn();
		Statement stmt = conn.createStatement();
		stmt.execute(sql);
		conn.close();
		stmt.close();
	}
	*/
}

 

com.tinstu.domain--->Customer.java

package com.tinstu.domain;
/**
 * 领域对象
 * 与表单和数据库对应
 * @author Tin
 *
 */

//对应数据库
public class Customer {
	private String cid ; //id
	private String cname ; //姓名
	private String gender;
	private String birthday; //生日
	private String cellphone ; //电话
	private String email;  //邮箱
	private String description; //描述
	public String getCid() {
		return cid;
	}
	public void setCid(String cid) {
		this.cid = cid;
	}
	public String getCname() {
		return cname;
	}
	public void setCname(String cname) {
		this.cname = cname;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getCellphone() {
		return cellphone;
	}
	public void setCellphone(String cellphone) {
		this.cellphone = cellphone;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Override
	public String toString() {
		return "Customer [cid=" + cid + ", cname=" + cname + ", gender=" + gender + ", birthday=" + birthday
				+ ", cellphone=" + cellphone + ", email=" + email + ", description=" + description + "]";
	}
/*
	public Customer(String cid, String canme,String gender, String birthday, String cellphone, String email, String description) {
		super();
		this.cid = cid;
		this.cname = cname;
		this.gender = gender;
		this.birthday = birthday;
		this.cellphone = cellphone;
		this.email = email;
		this.description = description;
	}
	*/
}

 

 

com.tinstu.service---->CustomerService.java

package com.tinstu.service;

import java.sql.SQLException;
import java.util.List;

import com.tinstu.dao.CustomerDao;
import com.tinstu.domain.Customer;

/**
 * 业务层
 * @author Tin
 *
 */

public class CustomerService {
	CustomerDao cd = new CustomerDao();
	private CustomerDao customerDao = new CustomerDao();
	//add
	public void add(Customer c) {
		customerDao.add(c);
	}
	//查询所有
	public List<Customer> findAll() throws SQLException{
		return customerDao.findAll();
	}
	/*
	public void add(Customer c) throws SQLException {
		String sql = "insert into t_customers(cname,birthday,cellphone,email,descripation) values('"+c.getCname()+"','"+c.getBirthday()+"','"+c.getCellphone()+"','"+c.getEmail()+"','"+c.getDescription()+"')";
		System.out.println("执行的sql语句:"+sql);
		cd.updateBySql(sql);
	}
	*/
	//加载客户
	public Customer load(String cid) throws SQLException {
	
		return customerDao.load(cid) ;
	}
	//编辑客户
	public void edit(Customer c) throws SQLException {
		customerDao.edit(c);
		
	}
	//删除客户
	public void dele(String cid) throws SQLException {
		customerDao.dele(cid);;
	}
	//多条件查询
	public List<Customer> query(Customer criteria) throws SQLException {

		return customerDao.query(criteria);
		
	}


}

 

com.tinstu.servlet----> CustomerServlet.java

package com.tinstu.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tinstu.domain.Customer;
import com.tinstu.service.CustomerService;
import com.tinstu.units.BaseServletf;

import cn.itcast.commons.CommonUtils;
import cn.itcast.servlet.BaseServlet;

/**
 * web层
 * @author Tin
 *
 */

//public class CustomerServlet extends BaseServletf{
public class CustomerServlet extends BaseServletf{
	private CustomerService service = new CustomerService();

	/*
	 * 1.封装表单数据到Customer对象
	 * 2.补全cid,使用 uuid (无,数据库cid为递增)
	 * 3.使用service方法完成添加工作
	 * 4.向request域中保存成功的信息
	 * 5.转发 msg.jsp
	 */

	public String add(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		
		// 封装表单数据
		Customer customer = CommonUtils.toBean(request.getParameterMap(), Customer.class);
		// 给该客户添加一个id值
		customer.setCid(CommonUtils.uuid());
		// 调用Service层的方法进行添加客户
		service.add(customer);
		// 保存成功信息,并转发到msg.jsp页面
		request.setAttribute("msg", "恭喜,添加客户成功!");
		return "f:/msg.jsp";
	}
	
	//添加客户
	public String findAll(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException, SQLException {
		/*
		 * 1.调用service得到所有用户
		 * 2.保存到request域
		 * 3.转发list.jsp
		 */
		request.setAttribute("cstmList", service.findAll());
		return "f:/list.jsp";
	}
	//加载客户
	public String preEdit(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException, SQLException {
		/*
		 * 1.获取cid
		 * 2.使用cid来调用service方法,得到Customer
		 * 3.把Customer保存到request域中
		 * 4.转发edit.jsp显示在表单中
		 */
		String cid = request.getParameter("cid");
		Customer cstm = service.load(cid);
		request.setAttribute("cstm", cstm);
		return "f:/edit.jsp";
	}
	//编辑客户
	public String edit(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException, SQLException {
		/*
		 * 1.封装表单数据到Customer对象中
		 * 2.调用service方法完成修改
		 * 3.保存成功信息到request域
		 * 4.转发msg.jsp显示成功信息
		 */
		Customer c = CommonUtils.toBean(request.getParameterMap(), Customer.class);
		service.edit(c);
		request.setAttribute("msg", "恭喜,编辑客户成功");
		return "f:/msg.jsp";
	}
	//删除客户
	public String dele(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException, SQLException {
		String cid = request.getParameter("cid");
		service.dele(cid);
		request.setAttribute("msg", "恭喜,删除客户成功");
        return "f:/msg.jsp";
	}
	//高级搜素
	public String query(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException, SQLException {
		/*
		 * 1.封装表单数据到Customer对象中,它只有四个属性(cname,gender,cellphone,email)
		 *    它就是一个条件
		 *    2. 使用Customer调用service方法,得到List<Customer>
		 *    3.保存到request中
		 *    4.转发list.jsp
		 */
		Customer criteria =  CommonUtils.toBean(request.getParameterMap(), Customer.class);
		List<Customer> cstmList =  service.query(criteria);
		request.setAttribute("cstmList", cstmList);
		return "/list.jsp";
	}
}

 

com.tinstu.untils--->BaseServelt.java

package com.tinstu.units;

import java.io.IOException;
import java.lang.reflect.Method;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class BaseServletf extends HttpServlet {

	public void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		
		String methodName = request.getParameter("method");
		System.out.println(methodName);
		if(methodName == null && methodName.trim().isEmpty()) {
			throw new RuntimeException("你还没有提供method参数,不知道要调用哪个方法!");
		}
		
		Class c = this.getClass();
		
		Method method = null;
		
		try {
			method = c.getMethod(methodName, HttpServletRequest.class, HttpServletResponse.class);
		} catch (Exception e) {
			throw new RuntimeException("你要调用的方法:" + methodName + ",不存在!");
		}
		/*
		 * 调用method表示方法
		 */
		
		try {
			String result = (String) method.invoke(this, request, response);
			/*
			 * 获取请求处理方法执行后返回的字符串,它表示转发或者重定向的路径!
			 * 帮他完成转发或者重定向
			 */
			/*
			 * 查看返回的字符串是否含义冒号,如果没有,表示转发
			 * 如果有,使用冒号分割字符串,得到前缀和后缀
			 * 前缀放= f,转发,前缀= r 重定向. 后缀为路径
			 */
			
			if(result == null && result.trim().isEmpty()) {
				return;
			}
			
			if(result.contains(":")) {   //f://
				int index = result.indexOf(":");
				String start = result.substring(0, index);
				String path = result.substring(index + 1);
				
				if(start.equals("f")) {   //转发
					request.getRequestDispatcher(path).forward(request, response);
				} else if (start.equals("r")) {   //重定向
					response.sendRedirect(request.getContextPath() + path);
				} else {
					throw new RuntimeException("你指定的操作:"+ start +",当前版本还不支持");
				}
			} else { //没有冒号默认转发
				request.getRequestDispatcher(result).forward(request, response);
			}
			
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}

 

o3p0-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
	<default-config>
		<property name="driverClass">com.mysql.jdbc.Driver</property>
		<property name="jdbcUrl">jdbc:mysql://localhost:3306/customers</property>
		<property name="user">root</property>
		<property name="password">root</property>
		
		<property name="initialPoolSize">10</property>
		<property name="maxPoolSize">10</property>
		<property name="minPoolSize">3</property>
		<property name="acquireIncrement">3</property>
	</default-config>
</c3p0-config>

 

前端

index.jsp/frame.jsp

index.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<jsp:forward page="/frame.jsp" />

frame.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>主页</title>
</head>
<frameset rows="20%,*">
   <frame src='<%=request.getContextPath()%>/top.jsp' name="top" />
   <frame src='<%=request.getContextPath()%>/welcome.jsp' name="main" />
</frameset>

 

add.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'add.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<!-- jquery是js的框架,它封装很多功能,用起来比js方便很多 -->
	

  </head>
  
  <body>
<h3 align="center">添加客户</h3>
	<form action="<c:url value='/CustomerServlet' />" method="post">
	<!-- 向servlet传递一个名为method的参数,其值表示要调用servlet的哪一个方法 -->
	<input type="hidden" name="method" value="add">
		<table border="0" align="center" width="800px;" style="padding-left:250px">
			<tr>
				<td width="100px">客户名称</td>
				<td width="40%">
					<input type="text" name="cname" />
				</td>
				<td align="left" style="color:red;">
					<label id="cnameError" class="error">&nbsp;</label>
				</td>
			</tr>
			<tr>
				<td>客户性别</td>
				<td>
					<input type="radio" name="gender" value="male" id="male" />
					<label for="male">男</label>
					<input type="radio" name="gender" value="female" id="female" />
					<label for="female">女</label>
				</td>
				<td align="left" style="color:red;">
					<label id="genderError" class="error">&nbsp;</label>
				</td>
			</tr>
			
			<tr>
				<td>客户生日</td>
				<td>
					<input type="text" name="birthday" />
				</td>
				<td>
					<label id="birthdayError" class="error">&nbsp;</label>
				</td>
			</tr>
			
			<tr>
				<td>手机</td>
				<td>
					<input type="text" name="cellphone" />
				</td>
				<td>
					<label id="cellphoneError" class="error">&nbsp;</label>
				</td>
			</tr>
			
			<tr>
				<td>客户邮箱</td>
				<td>
					<input type="text" name="email" />
				</td>
				<td>
					<label id="emailError" class="error">&nbsp;</label>
				</td>
			</tr>
			
			<tr>
				<td>描述</td>
				<td>
					<textarea rows="5" cols="27" name="description"></textarea>
				</td>
				<td>
					<label id="descriptionError" class="error">&nbsp;</label>
				</td>
			</tr>
			
			<tr>
				<td></td>
				<td colspan="2">
					<input type="submit" value="添加用户" />
					<input type="reset" value="重置" />
				</td>
			</tr>
		</table>
	</form>
  </body>
</html>

 

edit.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'edit.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<h3 align="center">编辑客户</h3>
<form action="CustomerServlet" method="">
    <input type="hidden" name="method" value="edit">
    <input type="hidden" name="cid" value="${cstm.cid }">
	<table border="0" align="center" width="800px" style="padding-left:220px">
				<tr>
			<td width="100px">客户名称</td>
			<td width="40%">
				<input type="text" name="cname" value="${cstm.cname }" />
			</td>
			<td align="left" style="color:red;">
				<label id="cnameError" class="error">&nbsp;</label>
			</td>
		</tr>
		<tr>
			<td>客户性别</td>
			<td>
				<input type="radio" name="gender" value="male" id="male" <c:if test="${cstm.gender eq '男' }">checked='checked'</c:if>/>
				<label for="male">男</label>
				<input type="radio" name="gender" value="female" id="female" <c:if test="${cstm.gender eq '女' }">checked='checked'</c:if>/>
				<label for="female">女</label>
			</td>
			<td align="left" style="color:red;">
				<label id="genderError" class="error">&nbsp;</label>
			</td>
		</tr>
		
		<tr>
			<td>客户生日</td>
			<td>
				<input type="text" name="birthday" value="${cstm.birthday }"/>
			</td>
			<td>
				<label id="birthdayError" class="error">&nbsp;</label>
			</td>
		</tr>
		
		<tr>
			<td>手机</td>
			<td>
				<input type="text" name="cellphone" value="${cstm.cellphone }" />
			</td>
			<td>
				<label id="cellphoneError" class="error">&nbsp;</label>
			</td>
		</tr>
		
		<tr>
			<td>客户邮箱</td>
			<td>
				<input type="text" name="email" value="${cstm.email }"/>
			</td>
			<td>
				<label id="emailError" class="error">&nbsp;</label>
			</td>
		</tr>
		
		<tr>
			<td>描述</td>
			<td>
				<textarea rows="5" cols="30" name="description">${cstm.description}</textarea>
			</td>
			<td>
				<label id="descriptionError" class="error">&nbsp;</label>
			</td>
		</tr>
		<tr>
			<td></td>
			<td colspan="2">
				<input type="submit" value="提交保存" />
				<input type="reset" value="重置" />
			</td>
		</tr>
	</table>
</form>
  </body>
</html>

 

list.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'list.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
	<h3 align="center">客户列表</h3>
	<table border="1" width="70%" align="center">
		<tr>
			<th>客户姓名</th>
			<th>性别</th>
			<th>生日</th>
			<th>手机</th>
			<th>邮箱</th>
			<th>描述</th>
			<th>操作</th>
		</tr>
<c:forEach items="${requestScope.cstmList }" var="cstm">
    <tr>
      <td>${cstm.cname }</td>
      <td>${cstm.gender }</td>
      <td>${cstm.birthday }</td>
      <td>${cstm.cellphone }</td>
      <td>${cstm.email }</td>
      <td>${cstm.description }</td>
      <td>
         <a href="/Customer/CustomerServlet?method=preEdit&cid=${cstm.cid }">编辑</a>
         <a href="/Customer/CustomerServlet?method=dele&cid=${cstm.cid }">删除</a>
      </td>
    </tr>
</c:forEach>
		
	</table>
<br/>
  </body>
</html>

 

msg.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'msg.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<h2 style="text-align:center;color:purple;">恭喜,${ msg }</h2>
  </body>
</html>

 

query.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'query.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<h3 align="center">高级搜索</h3>
<form action="<c:url value='/CustomerServlet' />" method="post">
 <input type="hidden" name="method" value="query" />
	<table border="0" align="center" width="800px" style="padding-left:220px">
		<tr>
			<td width="100px">客户名称</td>
			<td>
				<input type="text" name="cname" />
			</td>
		</tr>
		<tr>
			<td>客户性别</td>
			<td>
				<select name="gender">
					<option value="">===请选择性别===</option>
					<option value="男">男</option>
					<option value="女">女</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>手机</td>
			<td>
				<input type="text" name="cellphone" />
			</td>
		</tr>
		<tr>
			<td>邮箱</td>
			<td>
				<input type="text" name="email" />
			</td>
		</tr>
		<tr>
			<td></td>
			<td>
				<input type="submit" value="搜索" />
				<input type="reset" value="重置" />
			</td>
		</tr>
	</table>
</form>
  </body>
</html>

 

top.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<!-- base:作用是为本页面所有的表单和超链接指定显示内容的框架! -->
<base target="main">
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body style="text-align: center;">
  <h1>客户管理系统</h1>
  <a href="<%=request.getContextPath()%>/add.jsp">添加客户</a>
  <a href="<%=request.getContextPath()%>/CustomerServlet?method=findAll">查询客户</a>
  <a href="<%=request.getContextPath()%>/query.jsp">高级搜索</a>
</body>
</html>

 

welcome.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'welcome.jsp' starting page</title>
  </head>
  
  <body>
  <br/>
  <br/>
<h2 align="center">欢迎登录客户管理系统</h2>
  </body>
</html>

 

阅读剩余
THE END