how to return excel in Struts2 result?

后端 未结 3 570
眼角桃花
眼角桃花 2020-12-17 06:31

I am trying to return an Excel sheet from my struts2 action class.

I am not sure what result-type should I be using? Has anyone tried to return an excel from strut

3条回答
  •  生来不讨喜
    2020-12-17 07:06

    You can utilize the Stream Result type

    an Example will look like this:

    
        application/vnd.ms-excel
        excelStream
        attachment; filename="${fileName}"
        1024
        ${contentLength}
     
    

    excelStream will be a method in your action class, contentLength will be length of the stream, fileName will be a getter which will return back the name of the file.

提交回复
热议问题