layui多文件上传springMVC后端处理

本文介绍了如何使用layui前端框架结合SpringMVC实现多文件上传。前端通过layui的多文件上传组件,每个文件发送单独的上传请求。后端只需处理单文件上传的Controller,配合SpringMVC配置,完成文件接收与存储。
摘要由CSDN通过智能技术生成


效果预览:
在这里插入图片描述

使用框架:SSM

前端jsp

使用layui的多文件上传组件,官网地址:https://www.layui.com/demo/upload.html 。在标签里引入layui的css以及js文件,更改js代码的请求上传接口即可。代码如下:

    <%@ page contentType="text/html;charset=utf-8" %>
    <html>
    <head>
        <title>文件寄存</title>
        <link rel="stylesheet" href="/static/css/layui.css" media="all">
        <script src="/static/layui.js"></script>
        <script
                src="https://code.jquery.com/jquery-3.4.1.js"
                integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
                crossorigin="anonymous"></script>
        <style>
            .c{
                width: 800px;
                margin: 50px auto;
            }
        </style>
    </head>
    <body>
    <%@include file="navigation.jsp"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <div class="c">
        <c:if test="${u == null}"><label class="layui-form-item">登录后即可上传文件</label></c:if>
        <c:if test="${u != null}">
    <div class="layui-upload">
        <button type="button" class="layui-btn layui-btn-normal" id="testList">选择多文件</button>
        <div class="layui-upload-list">
            <table class="layui-table">
                <thead>
                <tr><th>文件名</th>
                    <th>大小</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr></thead>
                <tbody id="demoList"></tbody&g
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值