JSP to export data from the database to the implementation of Excel download
Key code:
<%@ page contenttype= "Application/msexcel"%>
<%
Response.setheader ("content-disposition", "inline; Filename=videos.xls");
Response.setheader ("Content-disposition", "attachment; Filename=test.xls");
The above line sets the filename to Test.xls when it is passed to the front-end browser.
This is the line that allows the front-end browser to assume that an Excel file is received
%>
Simple Test Example:
<%@ page language= "java" import= "java.util.*,java.io.*" pageencoding= "GBK"%> <%@ page contenttype= "
Application/msexcel "%> <%//response.setheader (" content-disposition "," inline; Filename=videos.xls ");
Response.setheader ("Content-disposition", "attachment; Filename=test.xls"); The above line sets the file name Test.xls//That is to be sent to the front-end browser to allow the front-end browser to receive an Excel file%> <%@ page import= Org.springframework.web.context.WebApplicationContext "%> <%@ page import=" com.test.* "%> <%@ page import= "Org.springframework.web.context.support.WebApplicationContextUtils"%> <% String Path =
Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; %> <% Webapplicationcontext ctx = Webapplicationcontextutils.getwebapplicationcontext (This.getServletContext (
));
Usermanager um = (usermanager) ctx.getbean ("Usermanager"); %> <!
DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >