Use agular2 for file upload. Note: "zhuodi tornado" and "agular2" file upload.
(-1) Function Description
Write a function. The foreground initiates a request to execute tasks in the background. The foreground can obtain the execution progress and obtain the final execution status.
(0) angular2 $ http File Upload
Angular-file-upload is not used here to share code.
var time = new Date().getTime();var obj = {method:"POST",url:"csvFile",headers : { 'Content-Type':undefined},transformRequest: function() { var formData = new FormData(); formData.append('file', $('#uploadBtn')[0].files[0]); formData.append('time',time); return formData; }}
'Content-type': undefined
TransformRequest
I have some online comments about these two parts. I have limited capabilities. I only know the results of doing so, but I don't know if they are right. I hope you can give me some advice.
(1) how to deal with multithreading
Because the interface for returning progress and final status is provided, HashMap is used in the background to store information. The number of milliseconds passed in at the front end is marked.
Removed the use of many member variables and changed to passing parameters.
Note that the front-end sends an execution request and then sends an execution progress request. In the return progress method, I wrote the following:
This writing has laid the root of the disaster, and has done bad things with good intentions. This kind of mistake is not intuitively displayed. Troubleshooting is also a great deal of effort.
Integer rate = rateMap.get(time) ;if(rate !=null){if(rate == 100){rateMap.remove(time);return 100;}else{return rate;}}else{return 100;}
Finally, if it is null, 0 is returned.
(2) How to export maven project groups, multi-module projects, and multiple maven Projects
In fact, you only need to export the main project (a single project) according to the normal operation. My Baidu ....
(3) Insert data
Another mistake is made here, because there will be a lot of null data. The previous writing is that when a field is null, the dao Layer Code will not be executed.
In fact, as long as the id is not null, the code is changed, and non-main data is null, the program can still execute the dao layer code.