SSM框架实现多图片上传

第一步:首先得有一个文件夹 

第二步:上传图片的jsp页面中的代码: 

<form action="${pageContext.request.contextPath}/addImg" method="post" enctype="multipart/form-data">
    <table >
        <tr>
            <td>上传图片:</td>
            <td><input type="file" name="file" /></td>    
            <td><input type="file" name="file" /></td>        
            <td><input type="file" name="file" /></td><!--这个name=“file”并不是数据库的属性名哦-->
        </tr>
    </table>
    <button type="submit" >保存</button>
</form>

显示图片的jsp页面中的代码

<c:forEach var="b" items="${imgList}">
    <img src="http://localhost:8080/你的项目名/${b.img}">
</c:forEach>
第三步:上传图片的Controller类的代码(这里面的“upimages”就是我们创建的文件夹的名称)

猜你喜欢

转载自blog.csdn.net/zalan01408980/article/details/82813758