5

私の問題は、Struts2を使用してjspで生成されたPDFを表示できないことです。

struts2でDynamicJasperを使用して動的にPDFを生成することができ、また、

を使用してダウンロードします

result type = "stream"私が立ち往生している唯一の問題は、PDFをjspで表示することです。私はできる

iframeタグを使用して表示しますが、実行時に生成したものではなく、古いpdfを表示します。

誰かが何か提案があれば、事前に感謝を助けてください

4

1 に答える 1

6
Action Class 

public class GeneratePdf extends ActionSupport
{
    public InputStream inputStream;
    File file = new File("D:\\workspace\\desktopApp\\HRIS_Updated\\WebContent\\Jasper\\hris.employee.report.AwardReport.pdf");
    public String execute(){

            try {

            inputStream = new DataInputStream( new FileInputStream(file));

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
   return SUCCESS;
}
public void setInputStream(InputStream inputStream) {
        this.inputStream = inputStream;
    }



public InputStream getInputStream() {
        return inputStream;
    }
}

.xml ファイル内

<action name="GeneratePdf" class="hris.report.action.GeneratePdf">
            <result name="success" type="stream">
                <param name="contentType">application/pdf</param>
                <param name="inputName">inputStream</param>
                <param name="contentDisposition">inline;filename="test.pdf"</param>
                <param name="bufferSize">1024</param>
            </result>
        </action>

それが役に立てば幸い :)

于 2012-08-14T15:11:04.917 に答える