
第1页 / 共4页

第2页 / 共4页

第3页 / 共4页

第4页 / 共4页




上传Controller类
*上传文件的Controller
* @Author MengMeng * @Date 2018/10/6 * @version: 0.1 * @since JDK 1.80_144 */ @Controller @RequestMapping("/upload") public class UploadController { @Autowired private HttpServletRequest request; @Autowired private ExcelService excelService; //跳转到上传文件的页面 @RequestMapping(value = "", method = RequestMethod.GET) public String goUpload() { //跳转到 templates 中tools目录下的 upload.html return "tools/upload"; } @RequestMapping(value = "/excel",method = RequestMethod.POST) public String upload(MultipartFile file, Model model) throws Exception { boolean flag = excelService.getExcel(file);用户实体类
* @ClassName User * @Author MengMeng * @Date 2018/10/6 * @Version: 0.1 * @Since JDK 1.80_171 */ @Entity @Table(name = "test", schema = "project") public class Excel implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(length=36) private String id; @Column(length=45,nullable=false,unique=true) private String username; @Column(length=100,nullable=false,unique=true) private String email; @Column(length=45,nullable=false) private String password; @Column(length=45) private String role; public Excel() { } public Excel(Excel user){ this.id = user.getId(); this.username = user.getUsername(); this.role = user.getRole(); this.email = user.getEmail(); this.password = user.getPassword(); } //get 和 set } Service: package org.meng.project.service; import com.alibaba.fastjson.JSON; import org.meng.project.entity.*; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.transaction.Transactional; /** *Excel的Service类接口
*Excel的Service类接口,与Excel有关的业务逻辑方法
* @Author MengMengExcel的Service类
*Excel的Service类,与User有关的业务逻辑方法
* @Author MengMeng * @Date 2018/10/6 * @version: 0.1 * @since JDK 1.80_144 */ @Service public class ExcelServiceImpl implements ExcelService { @Autowired private ExcelRepository excelRepository; @Override public boolean getExcel(MultipartFile file) throws Exception { // TODO Auto-generated method stub ListExcel的DAO类接口
*Excel的DAO类接口,与Excel有关的持久化操作方法
* @Author MengMeng * @Date 2018/10/6 * @version: 0.1 * @since JDK 1.80_144 */ @Repository public interface ExcelRepository extends BaseRepository
2023年江西萍乡中考道德与法治真题及答案.doc
2012年重庆南川中考生物真题及答案.doc
2013年江西师范大学地理学综合及文艺理论基础考研真题.doc
2020年四川甘孜小升初语文真题及答案I卷.doc
2020年注册岩土工程师专业基础考试真题及答案.doc
2023-2024学年福建省厦门市九年级上学期数学月考试题及答案.doc
2021-2022学年辽宁省沈阳市大东区九年级上学期语文期末试题及答案.doc
2022-2023学年北京东城区初三第一学期物理期末试卷及答案.doc
2018上半年江西教师资格初中地理学科知识与教学能力真题及答案.doc
2012年河北国家公务员申论考试真题及答案-省级.doc
2020-2021学年江苏省扬州市江都区邵樊片九年级上学期数学第一次质量检测试题及答案.doc
2022下半年黑龙江教师资格证中学综合素质真题及答案.doc