Taking struts 2 as an example, Java introduces how to upload pictures

Generally speaking, there are two ways to upload pictures. One is to write picture files to the database, and the other is to save them to the server file directory. The picture files written to the database need to be converted into binary stream format, which takes up more database space and is suitable for the storage of a small number of pictures. For example, the advantage of writing some small icons in the system to the database is that they are relatively safe and not easy to be accidentally deleted by users.

Implemented in struts 2 (taking image upload as an example)

1.FileUpload. The JSP code list is as follows:

2.ShowUpload. The function list of JSP is as follows:

3.FileUploadAction. The code list of Java is as follows:

Note: at this time, for the convenience of implementing action, inherit actionsupport and override execute() method

In struts 2, any POJO can be used as an action

4.struts. The XML list is as follows:

5.web. The XML list is as follows:

The above content is all about how to upload pictures in Java struts 2. I hope you like it.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>