欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ssm自学curd入门 记录自己学习 方便以后查找

程序员文章站 2024-02-26 09:53:04
...
CustomerController.java
package com.shiep.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.shiep.pojo.Customer;
import com.shiep.pojo.Login;
import com.shiep.pojo.QueryVo;
import com.shiep.service.CustomerService;
@Controller
@RequestMapping("customer")
public class CustomerController {
	@Autowired
	private CustomerService customerService;
	@RequestMapping("list.do")
	public String list(QueryVo vo,Model model) {
		List<Customer> listAll = customerService.selectPageByQueryVo(vo);
		model.addAttribute("listAll", listAll);

		model.addAttribute("custName", vo.getCustName());
		model.addAttribute("custSource",vo.getCustSource());
		model.addAttribute("custIndustry", vo.getCustIndustry());
		model.addAttribute("custLevel", vo.getCustLevel());
		return "list";	
	}
	@RequestMapping(value="edit.do")
	public  String edit( Integer id,Model model){ 
		Customer customerById = customerService.selectCustomerById(id);
		model.addAttribute("customerById", customerById);
		return "update";
				
	}
	
	@RequestMapping(value="update.do")
	public String update( Customer customer){
		customerService.updateCustomerById(customer);
		return "list"; 
	
	}
	@RequestMapping(value="delete.do")
	public  String delete( Integer id){
		customerService.deleteCustomerById(id);
		return "list";  
		
	}
	
	
	@RequestMapping(value="tosave.do")
	private String tosave() {
		return "save";


	}
	@RequestMapping(value="save.do")
	public  String save( Customer customer){
		customerService.saveCustomer(customer);
		return "list"; 
		
	}
	
	@RequestMapping("login.do")
	public String login(Login vo){
		vo=this.customerService.customerLogin(vo);
		if(vo!=null){
			return "main";
		}else {
			return "error";
		}
	}
}
CustomerDao.java
package com.shiep.mapper;
import java.util.List;
import com.shiep.pojo.Customer;
import com.shiep.pojo.Login;
import com.shiep.pojo.QueryVo;
public interface CustomerDao {
	public Integer customerCountByQueryVo(QueryVo vo);
	public List<Customer> customerListByQueryVo(QueryVo vo);
	public  Customer selectCustomerById(Integer id);
	public void updateCustomerById(Customer customer);
	public void deleteCustomerById(Integer id);
	public void saveCustomer(Customer customer);
	public Login findLogin(Login vo);	

}
CustomerDao.xml
<mapper namespace="com.shiep.mapper.CustomerDao">
	<select id="customerCountByQueryVo" parameterType="QueryVo" resultType="Integer">
		select count(1) from customer
		<where>
			<if test="custName !=null and custName !=''">
				cust_name like "%"#{custName}"%"
			</if>
			<if test="custSource !=null and custSource !=''" >
				and cust_source = #{custSource}
			</if>
			<if test="custIndustry !=null and custIndustry !=''">
				and cust_industry = #{custIndustry}
			</if>
			<if test="custLevel !=null and custLevel !=''">
				and cust_level = #{custLevel}
			</if>
		</where>
	</select>
	<select id="customerListByQueryVo" parameterType="QueryVo" resultType="Customer">
		select * from customer
		<where>
			<if test="custName !=null and custName !=''">
				cust_name like "%"#{custName}"%"
			</if>
			<if test="custSource !=null and custSource !=''" >
				and cust_source = #{custSource}
			</if>
			<if test="custIndustry !=null and custIndustry !=''">
				and cust_industry = #{custIndustry}
			</if>
			<if test="custLevel !=null and custLevel !=''">
				and cust_level = #{custLevel}
			</if>
		</where>
	</select>
	<select id="selectCustomerById" parameterType="Integer" resultType="Customer">
		select * from customer
		<where>
			cust_id=#{id}
		</where>
	</select>
	<update id="updateCustomerById" parameterType="Customer" >
		update customer 
		<set>
			<if test="cust_name !=null">
				cust_name=#{cust_name},
			</if>
			<if test="cust_source !=null">
				cust_source=#{cust_source},
			</if>
			<if test="cust_industry !=null">
				cust_industry=#{cust_industry},
			</if>
			<if test="cust_level !=null">
				cust_level=#{cust_level},
			</if>
			<if test="cust_linkman !=null">
				cust_linkman=#{cust_linkman},
			</if>
			<if test="cust_phone !=null">
				cust_phone=#{cust_phone},
			</if>
			<if test="cust_mobile !=null">
				cust_mobile=#{cust_mobile},
			</if>
			<if test="cust_zipcode !=null">
				cust_zipcode=#{cust_zipcode},
			</if>
			<if test="cust_address !=null">
				cust_address=#{cust_address}
			</if>
		</set>
		<where>
			cust_id= #{cust_id}
		</where>	
	</update>
	
 <delete id="deleteCustomerById" parameterType="Integer">
	delete from customer where cust_id=#{valve}
 </delete>
<insert  id="saveCustomer" parameterType="Customer" >
		insert into customer(cust_id,cust_name,cust_user_id,cust_create_id,cust_source,cust_industry,cust_level,cust_linkman,cust_phone,cust_mobile,cust_zipcode,cust_address,cust_createtime) 
		values(#{cust_id},#{cust_name},#{cust_user_id},#{cust_create_id},#{cust_source},#{cust_industry},
		#{cust_level},#{cust_linkman},#{cust_phone},#{cust_mobile},#{cust_zipcode},#{cust_address},#{cust_createtime})
</insert>
<select id="findLogin" parameterType="Login" resultType="Login">
 select * from login
    where username=#{username} and 
    	  password=#{password}
</select>	

</mapper>
Customer.java
package com.shiep.pojo;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
public class Customer {
	private Long cust_id;
	private String cust_name;
	private Long cust_user_id;
	private Long cust_create_id;
	private String cust_source;
	private String cust_industry;
	private String cust_level;
	private String cust_linkman;
	private String cust_phone;
	private String cust_mobile;
	private String cust_zipcode;
	private String cust_address;
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date cust_createtime;
	public Long getCust_id() {
		return cust_id;
	}
	public void setCust_id(Long cust_id) {
		this.cust_id = cust_id;
	}
	public String getCust_name() {
		return cust_name;
	}
	public void setCust_name(String cust_name) {
		this.cust_name = cust_name;
	}
	public Long getCust_user_id() {
		return cust_user_id;
	}
	public void setCust_user_id(Long cust_user_id) {
		this.cust_user_id = cust_user_id;
	}
	public Long getCust_create_id() {
		return cust_create_id;
	}
	public void setCust_create_id(Long cust_create_id) {
		this.cust_create_id = cust_create_id;
	}
	public String getCust_source() {
		return cust_source;
	}
	public void setCust_source(String cust_source) {
		this.cust_source = cust_source;
	}
	public String getCust_industry() {
		return cust_industry;
	}
	public void setCust_industry(String cust_industry) {
		this.cust_industry = cust_industry;
	}
	public String getCust_level() {
		return cust_level;
	}
	public void setCust_level(String cust_level) {
		this.cust_level = cust_level;
	}
	public String getCust_linkman() {
		return cust_linkman;
	}
	public void setCust_linkman(String cust_linkman) {
		this.cust_linkman = cust_linkman;
	}
	public String getCust_phone() {
		return cust_phone;
	}
	public void setCust_phone(String cust_phone) {
		this.cust_phone = cust_phone;
	}
	public String getCust_mobile() {
		return cust_mobile;
	}
	public void setCust_mobile(String cust_mobile) {
		this.cust_mobile = cust_mobile;
	}
	public String getCust_zipcode() {
		return cust_zipcode;
	}
	public void setCust_zipcode(String cust_zipcode) {
		this.cust_zipcode = cust_zipcode;
	}
	public String getCust_address() {
		return cust_address;
	}
	public void setCust_address(String cust_address) {
		this.cust_address = cust_address;
	}
	public Date getCust_createtime() {
		return cust_createtime;
	}
	public void setCust_createtime(Date cust_createtime) {
		this.cust_createtime = cust_createtime;
	}
}
Login.java
package com.shiep.pojo;
public class Login {
	Integer Id;
	String username;
	String password;
	String picture;
	public Integer getId() {
		return Id;
	}
	public void setId(Integer id) {
		Id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPicture() {
		return picture;
	}
	public void setPicture(String picture) {
		this.picture = picture;
	}

}
QueryVo.java
package com.shiep.pojo;
public class QueryVo {
	private String custName;
	private String custSource;
	private String custIndustry;
	private String custLevel;
	public String getCustName() {
		return custName;
	}
	public void setCustName(String custName) {
		this.custName = custName;
	}
	
	public String getCustSource() {
		return custSource;
	}
	public void setCustSource(String custSource) {
		this.custSource = custSource;
	}
	public String getCustIndustry() {
		return custIndustry;
	}
	public void setCustIndustry(String custIndustry) {
		this.custIndustry = custIndustry;
	}
	public String getCustLevel() {
		return custLevel;
	}
	public void setCustLevel(String custLevel) {
		this.custLevel = custLevel;
	}

}
CustomerService.java
package com.shiep.service;
import java.util.List;
import com.shiep.pojo.Customer;
import com.shiep.pojo.Login;
import com.shiep.pojo.QueryVo
public interface CustomerService {
	public List<Customer> selectPageByQueryVo(QueryVo vo);
	public  Customer selectCustomerById(Integer id);
	public void updateCustomerById(Customer customer);
	public void deleteCustomerById(Integer id);
	public void saveCustomer(Customer customer);
	public Login customerLogin(Login vo);		

}
CustomerServiceImpl.java
package com.shiep.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shiep.mapper.CustomerDao;
import com.shiep.pojo.Customer;
import com.shiep.pojo.Login;
import com.shiep.pojo.QueryVo;
@Service
public class CustomerServiceImpl implements CustomerService {
	@Autowired
	private CustomerDao customerDao;
	public List<Customer> selectPageByQueryVo(QueryVo vo) {
		return customerDao.customerListByQueryVo(vo);
	}
		@Override
		public Customer selectCustomerById(Integer id) {
			return customerDao.selectCustomerById(id);
		}
		@Override
		public void updateCustomerById(Customer customer) {
			customerDao.updateCustomerById(customer);
		}
		@Override
		public void deleteCustomerById(Integer id) {
			customerDao.deleteCustomerById(id);
			
		}
		@Override
		public void saveCustomer(Customer customer) {
			customerDao.saveCustomer(customer);
		}

		@Override
		public Login customerLogin(Login vo) {	
			return customerDao.findLogin(vo);
		}
}
SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 别名 -->
	<typeAliases> 
		<package name="com.shiep.pojo"/>
	</typeAliases>

</configuration>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
	
	<!-- 配置Service扫描 -->
	<context:component-scan base-package="com.shiep.service" />
	
	<!-- 配置 读取properties文件 jdbc.properties -->
	<context:property-placeholder location="classpath:jdbc.properties" />


	<!-- 配置 数据源 -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>
	<!-- 配置SqlSessionFactory -->
	<bean class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 设置MyBatis核心配置文件 -->
		<property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
		<!-- 设置数据源 -->
		<property name="dataSource" ref="dataSource" />
	</bean>
	<!-- 配置Mapper扫描 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- 设置Mapper扫描包 -->
		<property name="basePackage" value="com.shiep.mapper" />
	</bean>

</beans>
springmvc.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:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
	<!-- 配置Controller扫描 -->
	<context:component-scan base-package="com.shiep.controller" />
	<!-- 配置注解驱动 -->
	<mvc:annotation-driven />
	<!-- 配置视图解析器 -->
	<bean	class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>
</beans>
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" id="WebApp_ID" version="2.5">
  <display-name>ssm_curd</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  	<!-- 配置spring -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring/applicationContext.xml</param-value>
	</context-param>
	<!-- 配置监听器加载spring -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<!-- 配置过滤器,解决post的乱码问题 -->
	<filter>
		<filter-name>encoding</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encoding</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!-- 配置SpringMVC -->
	<servlet>
		<servlet-name>ssm_curd</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring/springmvc.xml</param-value>
		</init-param>
		<!-- 配置springmvc什么时候启动,参数必须为整数 -->
		<!-- 如果为0或者大于0,则springMVC随着容器启动而启动 -->
		<!-- 如果小于0,则在第一次请求进来的时候启动 -->
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>ssm_curd</servlet-name>
		<!-- 所有的请求都进入springMVC -->
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>
</web-app>
jdbc.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/curd?characterEncoding=utf-8
jdbc.username=root
jdbc.password=admin
list.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户列表</title>
</head>
<body>
<h1>客户管理系统 </h1>
<form action="<%=basePath %>customer/list.do" method="post">
客户名称:<input type="text"   name="custName" value="${custName }"><br/>
客户来源:
<select name="custSource" >
<option value="">--请选择--</option>
<option value="6">电话营销</option>
<option value="7">网络营销</option>
</select><br/>
所属行业:
<select  name="custIndustry">
<option value="">--请选择--</option>
<option value="1">教育培训</option>
<option value="2">电子商务</option>
<option value="3">对外贸易</option>
<option value="4">酒店旅游</option>
<option value="5">房地产</option>
</select><br/>
客户级别:
<select  name="custLevel">
<option value="">--请选择--</option>
<option value="22">普通客户</option>
<option value="23">VIP客户</option>
</select><br/>
<button type="submit"  onclick="window.location.href='<%=basePath %>customer/list.do'">查询</button>
</form>
<h3>客户信息列表</h3>
	<table >
		<thead>
			<tr>
				<th>ID</th>
				<th>客户名称</th>
				<th>客户来源</th>
				<th>客户所属行业</th>
				<th>客户级别</th>
				<th>固定电话</th>
				<th>手机</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${listAll}" var="row">
				<tr>
					<td>${row.cust_id}</td>
					<td>${row.cust_name}</td>
					<td>${row.cust_source}</td>
					<td>${row.cust_industry}</td>
					<td>${row.cust_level}</td>
					<td>${row.cust_phone}</td>
					<td>${row.cust_mobile}</td>
					<td>
    					<a href="<%=basePath %>customer/edit.do?id=${row.cust_id }">修改</a>/
    					<a href="<%=basePath %>customer/delete.do?id=${row.cust_id }">删除</a>
    				</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</body>

</html>
main.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>
</head>
<body>
<h1><font color="red">欢迎</font></h1>
    <a href="<%=basePath %>customer/tosave.do">保存客户</a><br/>
    <a href="<%=basePath %>customer/list.do">客户列表</a>
</body>

</html>
save.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>保存客户</title>
  </head>
  <body>
    <h1><font color="red">保存客户</font></h1>
     <form   action="<%=basePath %>customer/save.do"  method="post">
        cust_name:<input type="text" name="cust_name"> <br/>
        cust_source:<input type="text" name="cust_source"> <br/>
        cust_industry:<input type="text" name="cust_industry"> <br/>
        cust_level:<input type="text" name="cust_level"> <br/>
        cust_phone:<input type="text" name="cust_phone"> <br/>
        cust_mobile:<input type="text" name="cust_mobile"> <br/>
        <input type="submit"  value="保存">
     </form> <br/>
  </body>

</html>
update.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改客户信息</title>
</head>
<body>
<form action="<%=basePath%>customer/update.do" method="post" >
<h4>修改客户信息</h4>
<input type="hidden" name="cust_id" value="${customerById.cust_id }">
客户名称:<input type="text" name="cust_name" value="${customerById.cust_name }"><br/>
客户来源:<input type="text" name="cust_source" value="${customerById.cust_source }"><br/>  
<!-- <select name="custSource" >
<option value="">--请选择--</option>
<option value="6">电话营销</option>
<option value="7">网络营销</option>
</select><br/> -->
所属行业:<input type="text" name="cust_industry" value="${customerById.cust_industry }"><br/>
<!-- <select  name="custIndustry">
<option value="">--请选择--</option>
<option value="1">教育培训</option>
<option value="2">电子商务</option>
<option value="3">对外贸易</option>
<option value="4">酒店旅游</option>
<option value="5">房地产</option>
</select><br/> -->
客户级别:<input type="text" name="cust_level" value="${customerById.cust_level }"><br/>
<!-- <select  name="custLevel" id="custLevel">
<option value="">--请选择--</option>
<option value="22">普通客户</option>
<option value="23">VIP客户</option>
</select><br/> -->
联系人:<input type="text"  name="cust_linkman" value="${customerById.cust_linkman}"><br/>
固定电话:<input type="text" name="cust_phone" value="${customerById.cust_phone}"><br/>
移动电话:<input type="text" name="cust_mobile" value="${customerById.cust_mobile}"><br/>
邮政编码:<input type="text" name="cust_zipcode" value="${customerById.cust_zipcode}"><br/>
联系地址:<input type="text" name="cust_address" value="${customerById.cust_address}"><br/>
<input type="submit" value="修改">
</form>
</body>

</html>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录页面</title>
</head>
<body>
<form action="<%=basePath %>customer/login.do" method="post">
    	<table>
    		<tr>
    			<td>用户名</td>
    			<td><input type="text" name="username"></td>
    		</tr>
    		<tr>
    			<td>密码</td>
    			<td><input type="password" name="password"></td>
    		</tr>
    		<tr>
    			<td><input type="submit" value="登陆"></td>
    		</tr>
    	</table>
    </form>
</body>

</html>
customer表
# Host: 127.0.0.1  (Version: 5.5.15)
# Date: 2018-05-15 18:11:59
# Generator: MySQL-Front 5.3  (Build 4.269)

/*!40101 SET NAMES utf8 */;

#
# Structure for table "customer"
#

DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
  `cust_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT '客户编号(主键)',
  `cust_name` varchar(32) DEFAULT NULL COMMENT '客户名称(公司名称)',
  `cust_user_id` bigint(32) DEFAULT NULL COMMENT '负责人id',
  `cust_create_id` bigint(32) DEFAULT NULL COMMENT '创建人id',
  `cust_source` varchar(32) DEFAULT NULL COMMENT '客户信息来源',
  `cust_industry` varchar(32) DEFAULT NULL COMMENT '客户所属行业',
  `cust_level` varchar(32) DEFAULT NULL COMMENT '客户级别',
  `cust_linkman` varchar(64) DEFAULT NULL COMMENT '联系人',
  `cust_phone` varchar(64) DEFAULT NULL COMMENT '固定电话',
  `cust_mobile` varchar(16) DEFAULT NULL COMMENT '移动电话',
  `cust_zipcode` varchar(10) DEFAULT NULL,
  `cust_address` varchar(100) DEFAULT NULL,
  `cust_createtime` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`cust_id`),
  KEY `FK_cst_customer_create_id` (`cust_create_id`),
  KEY `FK_cst_customer_industry` (`cust_industry`),
  KEY `FK_cst_customer_level` (`cust_level`),
  KEY `FK_cst_customer_source` (`cust_source`),
  KEY `FK_cst_customer_user_id` (`cust_user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=184 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

#
# Data for table "customer"
#

INSERT INTO `customer` VALUES (36,'令狐冲',NULL,NULL,'6','5','23',NULL,'0108888887','13888888888',NULL,NULL,NULL)
login表
# Host: 127.0.0.1  (Version: 5.5.15)
# Date: 2018-05-15 18:12:15
# Generator: MySQL-Front 5.3  (Build 4.269)

/*!40101 SET NAMES gb2312 */;

#
# Structure for table "login"
#

DROP TABLE IF EXISTS `login`;
CREATE TABLE `login` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `picture` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `Id` (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;

#
# Data for table "login"
#

INSERT INTO `login` VALUES (1,'1','1','1'),(2,'admin','admin',NULL);

                                                                     ssm自学curd入门 记录自己学习 方便以后查找

                                                                         ssm自学curd入门 记录自己学习 方便以后查找