Struts 1.x を使用して PDF ファイルをダウンロードする際に少し問題があります。実際にファイルをダウンロードするときのファイル パスがわかりません。これまでのところ、私はこれを持っています:
protected StreamInfo getStreamInfo(ActionMapping mapping,ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String fileDir="/descargasPDF"; //directory where all files are created and located
String fileName="/tratado.pdf";
String contentType = "application/pdf";
//File file = new File(NOT SURE WHAT GOES HERE);
//I found this on the internet.
//But it doesn't creates the file on the fileDir directory.
File file = new File(request.getRealPath("/WEB-INF")+fileDir+fileName);
FileOutputStream f = new FileOutputStream(file);
......
}
PDFファイルをWEB-INFディレクトリに一時的に保存する必要があるかどうかはよくわかりませんが、これを別の方法で保存する方法がわかりません。これを行うためのより良い方法を知っている人はいますか?もしそうなら、どうすればできますか?
ありがとうございました。
編集
PDF を生成していることを指定するのを忘れており、iText 5.3 を使用しています。