Com. Urp. Command. fileframework (1)
A while ago I made a JSF project, a management system of a certain school. Although the project uses sping and hibernate, it still seems that some queries, edits, adds, and deletes. I have been working on this company for a year, and I have never skipped the slot. I don't know the outside world, I don't know how people write programs, it is always decided that the program written by the company has no technical content, no architecture, the concept of modules, and some are the same Layer 3.
When I first graduated from the company, I felt a little excited when I saw the three-tier model. Oh, the original program could be written like this. It turned out to be the legendary Three-tier model, and I immediately worshipped the designers. But now, design is the same, and writing is the same. It feels like a person can make a decision. How can it be lost. Think that the program outside should not be that simple. At least there are still a lot of things you can't understand in the blog garden.
Don't complain. Let's talk about what you want to write. The project itself does not have much new ideas, but it is quite interesting to import and export a piece of data. I wrote it in Java before, and because of the tight relationship between projects, I didn't think much about it during the writing. Now I am blank, and I find there are still many improvements.
The writing is not about how to import and export data, but about how to write data for upload and download. It is just a bit of personal experience after the project is completed. I hope you will not take it too seriously.
The main functions include import and export. Because it is a bsstructure, you may need to design upload and download. Therefore, we plan to start with uploading and downloading. Some of my friends may want to jump out and say that the upload I wrote may cause problems when uploading large files, so I have to say it again. This is just my experience and summary in the project, at least there is no need for large files in this project, and there seems to be no problem with 2 or 3 m database files, so we will not consider it for the moment. In addition, if the relationship between classes and classes is well designed, it is not difficult to increase the demand.
The import and export process is simplified as follows:
Class diagram of the uploaded part:
Uploadfileframe inherits the ifileframe interface. ifileframe has an ifileapi attribute and an execute method. We hope that uploadfileframe is a class similar to the appearance mode. You only need to call an execute method. Imagine that downloadfileframe, importfileframe, and exportfileframe in the future will only provide this method for external users and use a uniform name. This is also to make it possible to adopt the command mode in programs in the future, this facilitates some log or permission verification extensions.
Ifileapi reads and writes specific types of files, such as Excel and MDB. Because at present, each operation on these files in Java requires a different package, so should C. However, some of them are uniform. As a simple write, creation, and deletion of binary files, they should all be the same. Therefore, this part is stored in localfile. The class diagram is as follows:
Use an htmlinputfile control on the page. The background code calls the uploadfileframe constructor. here you need to input a system. Web. httppostedfile, where all the information about the uploaded file is included. The entire upload process is as follows: