又见乱码!!!
我的WEB中加了一个按钮,是将报表显示为Excel格式,代码为:
<form name='excel' action="../excel.xls" onSubmit="return setContent();" method='post'>
<div style="display:none">
<input name='report' type=text >
</div>
<input type="image" src="/sub/img/Excel2.gif" STYLE='POSITION:ABSOLUTE; RIGHT:20; TOP:5; cursor:"hand"'></input>
</form>
<SCRIPT>
function setContent(){
excel.report.value=document.all.REPORT_CONTENT.outerHTML;
return true;
}
</SCRIPT>
excel.xls文件为:
<%@page contentType="application/vnd.ms-excel;charset=GB2312" %>
<%@page import="utilplus.*"%>
<HTML>
<HEAD>
<META content='text/xls; charset=gb2312' http-equiv=Content-Type>
</HEAD>
<body>
<%
String content = request.getParameter("report");
out.println(content);
%>
</body>
</HTML>
在web.xml中添加了如下设置:
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.xls</url-pattern>
</servlet-mapping>
但是点击excel按钮就出现乱码,我该怎么办?谢谢!