logo资料库

非常详细的用 java(springmvc+mybatis)实现excel导入功能并且保存到数据库.docx

第1页 / 共21页
第2页 / 共21页
第3页 / 共21页
第4页 / 共21页
第5页 / 共21页
第6页 / 共21页
第7页 / 共21页
第8页 / 共21页
资料共21页,剩余部分请下载后查看
excel导入功能
POI基本jar
jsp页面内容:
addCustomer3.jsp
实体类entity:
Customer.java
dao层:
service
CustomerService.java
CustomerServiceImpl.java
tools
ReadExcel.java
StringToDateConverter.java
WDWUtil.java
Controller
AddController.java
excel 导入功能 POI 基本 jar jsp 页面内容: addCustomer3.jsp <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <% String importMsg=""; if(request.getSession().getAttribute("msg")!=null){ importMsg=request.getSession().getAttribute("msg").toString(); } request.getSession().setAttribute("msg", ""); %> 批量导入客户
批量导入客户
enctype="multipart/form-data" onsubmit="return check();">
<%=importMsg%> 实体类 entity: Customer.java package entity;
import java.io.Serializable; public class Customer implements Serializable { /** * */ private static final long serialVersionUID = 1604009282359281470L; private int id; private String name; private String code; private String industry; private String come; private String address; private String remark; public int getId() { return id; } public void setId(int id) { this.id = id; }
public Customer(int id, String name, String code, String industry, String come, String address, String remark) { super(); this.id = id; this.name = name; this.code = code; this.industry = industry; this.come = come; this.address = address; this.remark = remark; } public Customer() { super(); // TODO Auto-generated constructor stub } public String getName() { return name; } public void setName(String name) {
this.name = name; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getIndustry() { return industry; } public void setIndustry(String industry) { this.industry = industry; } public String getCome() { return come; } public void setCome(String come) { this.come = come; } public String getAddress() { return address;
} public void setAddress(String address) { this.address = address; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } } dao 层: CustomerMapper package dao; import entity.Customer; public interface CustomerMapper { public void insertCustomer(Customer customer);
} CustomerMapper.xml INSERT INTO `customer` ( `name`, `code`, `industry`, `come`, `adress`, `remark` ) VALUES ( #{name},
#{code}, #{industry}, #{come}, #{address}, #{remark} ) service CustomerService.java package service; import java.util.List; import org.springframework.web.multipart.MultipartFile;
分享到:
收藏