protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub /* * 输出一个excel * */ response.setContentType("application/vnd.ms-excel"); PrintWriter out = response.getWriter(); out.println(" Q1 Q2 Q3 Q4 Total"); out.println("Apples 90 40 49 55"); out.println("Oranges 90 40 49 55"); }
返回一个excel表格
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.setContentType("image/jpeg"); InputStream in = this.getClass().getClassLoader().getResourceAsStream("t.jpg"); byte[] b = new byte[in.available()]; in.read(b); OutputStream out = response.getOutputStream(); out.write(b); out.close(); in.close(); }
显示一张图片