See also file upload-fileUpLoad and fileupload multi-File Upload
This is the third time I wrote an essay about File Upload. I am also drunk in order to upload this file. If you don't talk nonsense, let's talk about the problem below:
There is a file upload function in the project, so it is hard to write the upload function. There is no problem in running locally, so that the file is okay, and then the project is deployed on the server to run, however, after being deployed to the server, other functions are normal. But when submitting a form with file upload, an error is always reported. What error is reported?
No result defined for action one of the most disgusting errors is wood? There is only one such mistake, and nothing else. I don't know how to solve it, and then I began to search for a solution on the Internet. I have encountered similar problems before, then, use the following method to solve the problem:
This is an error reported by an interceptor of struts2. When there is a problem with the data in your form, for example
<Input type = "text" name = "receiverLoginID" value = "<% = name %>"/>
This error occurs when the name value is NULL, so you can add the following labels on the current page.
<Div><S: fielderror/>
</Div>
It will display the interceptor error and add the corresponding action in the struts XML as shown in
<Result name = "input">/AddProducts. jsp </result>
Let him return the error to this page.
But the result is a file upload problem.
What is the problem with the <s: debug> label ?. The system path of the tmp file cannot be found. What's going on? When uploading files, the system will generate a temporary file and save it. Then, there is a folder in my struts. xml file that stores temporary files,
<! -- Path for temporary file storage -->
<Constant name = "struts. multipart. saveDir" value ="C:/test"> </Constant>
But at the beginning, I wrote:
<! -- Path for temporary file storage -->
<Constant name = "struts. multipart. saveDir" value ="E:/test"> </Constant>
Some people will say that it is not just to change the storage path of temporary files? No problem, but the key is that there is only a drive C on the server. How can this problem be solved without an edisk? When uploading files, the system cannot find the location where the temporary files are stored. Therefore, an error must be reported. You need to pay more attention to these things in the future. Writing a program is not a simple task to complete the function. There are still many improvements to be made in the future. Continue to work hard !!!