还有人也许会问:我在jsp开头加上<%@page c %>这一句,去掉response.setContentType("application/vnd.ms-excel");行不行?回答这个问题很简单,就是查看jsp服务器编译jsp后生成的java代码,如果改成这样,我的welogic7编译test_excel.jsp后生成的java文件的示意性代码是这样的:
public void _jspService(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws java.io.IOException,
javax.servlet.ServletException {
// declare and set well-known variables:
javax.servlet.ServletConfig config = getServletConfig();
javax.servlet.ServletContext application = config.getServletContext();
javax.servlet.jsp.tagext.Tag _activeTag = null;
// variables for Tag extension protocol