Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the function of uploading single file and multiple files by spring webflow in java development

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail "java development of spring webflow how to upload a single file and multiple files function", detailed content, clear steps, details handled properly, I hope that this "java development of spring webflow how to upload a single file and multiple files function" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

Upload a single file

Prepare for

1. If you use spring security in your project, refer to the previous article, use the second method in the previous article, and remove MultipartFilter (if any), otherwise you won't get the file.

two。 Variables in the process, such as those defined with var tags, need to implement the Serializable interface.

Realization process

Add the following dependencies to the pom.xml file:

Commons-fileupload commons-fileupload 1.2.1 commons-io commons-io 2.4

Add a file upload parser to spring-servlet.xml (Spring MVC's configuration file):

Entity class, remember that to implement the Serializable interface, the attribute type is MultipartFile:

@ Componentpublic class GoodsEntity implements Serializable {private static final long serialVersionUID = 1L; private MultipartFile images; public MultipartFile getImages () {return images;} public void setImages (MultipartFile images) {this.images = images;}}

Process definition code, nothing special:

Upload the form code without special configuration:

Pictures of goods:

That's it.

Upload multiple files

Uploading a single file can be achieved with a slight modification on the basis of the previous upload sheet.

Realize

First, the entity class needs to be modified to use List to store multiple files:

@ Componentpublic class GoodsEntity implements Serializable {private static final long serialVersionUID = 1L; private List images; public List getImages () {return images;} public void setImages (List images) {this.images = images;}}

The upload form also needs to be modified:

Pictures of goods:

Just add a multiple= "multiple" attribute.

Read this, the "java development of spring webflow how to upload a single file and multiple files function" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report