package com.demo;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;

@WebServlet("/excel.do")
public class ExcelServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        // 设置响应头，告诉浏览器这是一个HTML页面
        response.setContentType("text/html;charset=gb2312");

        // 获取输出流
        PrintWriter out = response.getWriter();

        // 输出HTML内容
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>学生信息表</title>");
        out.println("<style>");
        out.println("table { border-collapse: collapse; width: 50%; }");
        out.println("th, td { border: 1px solid black; padding: 8px; }");
        out.println("</style>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h2>学生信息表</h2>");
        out.println("<table>");
        out.println("<tr><th>学号</th><th>姓名</th><th>性别</th><th>年龄</th><th>所在系</th></tr>");
        out.println("<tr><td>95001</td><td>李勇</td><td>男</td><td>20</td><td>信息</td></tr>");
        out.println("<tr><td>95002</td><td>刘晨</td><td>女</td><td>19</td><td>数学</td></tr>");
        out.println("</table>");
        out.println("</body>");
        out.println("</html>");
    }
}