开发者

How do I configure Struts 2 to return a generated PDF?

开发者 https://www.devze.com 2023-04-11 23:51 出处:网络
<action name=\"trial_employee\" class=\"parity.action.Tri开发者_StackOverflow社区alPrintEmployeeCopyAction\">
<action name="trial_employee" 
        class="parity.action.Tri开发者_StackOverflow社区alPrintEmployeeCopyAction">
  <result>/protected/trial_employee.pdf</result>
</action>

I've got an action class that generates a PDF file for download. How do I configure the action result to return the PDF?

The above doesn't work, it gives me a 404 error because the pdf isn't physically on the drive, it's being generated dynamically.


If it is being generated dynamically you can return it as a stream something like

<result name="pdf  File" type="stream">
<param name="contentType">${contentType}</param>
</result>

more details are here

Stream result

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号