Spring MVC实现文件上传

Posted 小王Java

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring MVC实现文件上传相关的知识,希望对你有一定的参考价值。

Spring MVC实现文件上传

本周为大家带来Web开发中最常用的技术,文件上传,Spring MVC实现文件上传并查看图片文件

数据表

employee

CREATE TABLE `employee` (
`e_id` int(11) NOT NULL AUTO_INCREMENT,
`e_name` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 员工姓名,
`e_sex` int(11) DEFAULT NULL COMMENT 员工性别:0:男 1:女,
`e_head_pic` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 员工头像,
`e_join_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 入职日期,
PRIMARY KEY (`e_id`)
)

效果图

Spring

项目结构

Spring

Java源码结构

Spring

配置文件结构

Spring

前端结构

Spring

环境搭建

使用Maven创建Web项目

​IDEA创建JavaWeb项目并配置Tomcat​

整合SSM框架

​整合SSM​

配置Tomcat虚拟访问路径

​配置Tomcat虚拟访问路径​

pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>SSMFileUpload</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>

<!-- mybatis依赖的坐标 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.4</version>
</dependency>

<!-- java连接mysql的驱动坐标 -->
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstlSpring MVC文件上传

Spring MVC 上传文件

Spring MVC带进度条的多文件上传

如何在spring mvc 里加入监听器,来监听文件上传进度条

求教Spring mvc 处理 ajax问题,在线等

Spring MVC 之文件上传