Mainly added to the JSP page
<% @ Page contenttype = "application/MSExcel; charset = GBK" %>
<%
Response. setheader ("content-disposition ",
"Attachment; filename=shouexcel.xls ");
%>
The complete page is as follows:
<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>
<% @ Taglib uri = "http://struts.apache.org/tags-bean" prefix = "Bean" %>
<% @ Taglib uri = "http://struts.apache.org/tags-html" prefix = "html" %>
<% @ Taglib uri = "http://struts.apache.org/tags-logic" prefix = "logic" %>
<% @ Taglib uri = "http://struts.apache.org/tags-tiles" prefix = "tiles" %>
<% @ Page contenttype = "application/MSExcel; charset = GBK" %>
<%
Response. setheader ("content-disposition ",
"Attachment; filename=shouexcel.xls ");
%>
<HTML>
<Head>
<Title> export </title>
</Head>
<Body>
<Table width = "100%" border = "1" cellpadding = "1" cellspacing = "1">
<Tr>
<TD Height = "22">
<Div align = "center">
<Strong> device name </strong>
</Div>
</TD>
<TD Height = "22">
<Div align = "center">
<Strong> Error Type </strong>
</Div>
</TD>
<TD Height = "22">
<Div align = "center">
<Strong> Times </strong>
</Div>
</TD>
<TD>
<Div align = "center">
<Strong> time </strong>
</Div>
</TD>
<TD Height = "22">
<Div align = "center">
<Strong> TS </strong>
</Div>
</TD>
<TD Height = "22">
<Div align = "center">
<Strong> service </strong>
</Div>
</TD>
<TD Height = "22">
<Div align = "center">
<Strong> error message </strong>
</Div>
</TD>
</Tr>
<Logic: iterate id = "alarms" name = "alist">
<Tr>
<TD Height = "20">
<Div align = "center">
<Bean: write name = "alarms" property = "devicename"/>
</Div>
</TD>
<TD Height = "20">
<Div align = "center">
<Bean: write name = "alarms" property = "err_type_name"/>
</Div>
</TD>
<TD Height = "20">
<Div align = "center">
<Bean: write name = "alarms" property = "count"/>
</Div>
</TD>
<TD Height = "20">
<Div align = "center">
$ {Alarms. start_time }.
</Div>
</TD>
<TD Height = "20">
<Div align = "center">
<Bean: write name = "alarms" property = "ts_id"/>
</Div>
</TD>
<TD Height = "20">
<Div align = "center">
<Bean: write name = "alarms" property = "stream_id"/>
</Div>
</TD>
<TD Height = "20">
<Div align = "center">
<Bean: write name = "alarms" property = "descrption"/>
</Div>
</TD>
</Tr>
</Logic: iterate>
</Table>
</Body>
</Html>