package cn.itsource._03LoginServlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.itsource.dao.impl.StudentDaoImpl;
import cn.itsource.domain.Student;
public class LginSerylet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//返回浏览器,处理乱码问题text[server.xml Context]/html
resp.setContentType("text/html;charset=UTF-8");
PrintWriter writer = resp.getWriter();
StudentDaoImpl sd = new StudentDaoImpl();
List<Student> list = sd.queryAll();
System.out.println(list);
writer.println("<table border=1>");
for (Student stu : list) {
writer.println("<tr>");
writer.println("<td><input type = text value="+stu.getId()+"></td>");
writer.println("<td><input type = text value="+stu.getUsername()+"></td>");
writer.println("<td><input type = text value="+stu.getPassword()+"></td>");
writer.println("<td><input type = text value="+stu.getAge()+"></td>");
writer.println("<td><input type = text value="+stu.isSex()+"></td>");
writer.println("<td><input type = text value="+stu.getIntro()+"></td>");
writer.println("<td><a href=#>删除</a></td>");
writer.println("<td><a href=#>修改</a></td>");
writer.println("</tr>");
}
writer.println("<tr><td colspan=8>添加</td></tr>");
writer.println("</table>");
writer.close();
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
}