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 download WebWork files

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article analyzes "how to download WebWork files". The content is detailed and easy to understand. Friends who are interested in "how to download WebWork files" can follow the editor's idea to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's learn more about "how to download WebWork files" with the editor.

First of all, in an ACTION, if it is determined that you have permission to download the file.

1. Read the download file and generate a stream. This is the * * step for downloading the WebWork file, and the file name should be read from the requested request or extracted from the user's table.

Public String downLoadFile (String fileName) {try {File input = new File ("e:/engilish literature.doc"); docStream = new FileInputStream (input); contentDisposition = "filename=\" test.txt\ ";} catch (FileNotFoundException e) {/ / TODO Auto-generated catch block e.printStackTrace ();} return" download ";}

2. Direct the output to a special RESULT. It is called Steam Result in the WebWork file download.

Name= "success" type= "dispatcher" > name= "location" > / home/register-result.jsp name= "input" > name= "location" > / home/register.jsp name= "download" type= "stream" > name= "contentType" > application / x-msdownload name= "inputName" > docStream name= "bufferSize" > 1024 name= "contentDisposition" > ${contentDisposition} name= "params" / > action >

3. Download parameters of WebWork file. There are several parameters that need to be configured:

◆ contentType can be set to application/x-msdownload. In this way, the browser will ensure that a dialog box for downloading the file will pop up.

◆ inputName this is more important, this name is the name of the input stream, which will be looked up in the implementation class of steam result according to the expression of OGNL.

◆ contentDisposition this is the name of the file saved on the client side after download.

◆ ${contentDisposition} take a look at the code. If you write it in the above way, you will have the opportunity to set the file name in ACTION.

4, another parameter: contentLength is the size of the download file, the stream result implementation of webwork seems to have a problem, can not be dynamically set according to the size of the file, can only be written dead.

The meaning of this parameter is to tell the browser how big the downloaded file is so that the browser can display the progress bar correctly. If this function is important, you can write a new RESULT to implement it.

On how to download WebWork files to share here, I hope that the above content can make you improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

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

Development

Wechat

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

12
Report