######servlet跳转网页空白
######这是源代码
####网页显示空白,请问一下哪里错了。
package huat.com;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
/**
* Servlet implementation class editTeacher
*/
@WebServlet("/editTeacher.do")
public class editTeacher extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public editTeacher() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException {
doGet(request,response);
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=study2";
String userName="sa";
String userPwd="2020901015";
try{Class.forName(driverName);
System.out.println("加载驱动成功!");
}catch(Exception e){
e.printStackTrace();
System.out.println("加载驱动失败!");
request.setCharacterEncoding("utf-8");
response.setContentType("text/ html; charset=utf-8");
PrintWriter out = response.getWriter();
String teid=request.getParameter("teid");
String Teid=request.getParameter("Teid");
String Tename=request.getParameter("Tename");
String Tegender=request.getParameter("Tegender");
String Tedegree=request.getParameter("Tedegree");
String Tejob=request.getParameter("Tejob");
String Id=request.getParameter("Id");
try {
Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
Statement statement=dbConn.createStatement();
String sql="update 教师表 set 教师编号='"+Teid+"',tename='"+Tename+"',tegender='"+Tegender+"',tedegree='"+Tedegree+"',tejob='"+Tejob+"',id='"+Id+"'where teid='"+teid+"'";
response.setContentType("text/html; charset=utf-8");
PreparedStatement ps=dbConn.prepareStatement(sql);
ps.executeUpdate();
request.getRequestDispatcher("teachView.jsp").forward(request,response);
}catch (SQLException e1) {
e1.printStackTrace();
out.print("插入失败");
}return;
}
}
}