有人可以帮我看看为什么我的代码输入中文会失败啊?
在网页上输入中文到数据库失败,显示都是???
下面是代码:servlet的:
public class InsertNewSubject extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GB2312 ";
public void init() throws
ServletException {
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
request.setCharacterEncoding( "GB2312 ");
PrintWriter out = response.getWriter();
String stuNo1=request.getParameter( "stuNo ");
int stuNo=Integer.parseInt(stuNo1);
String stuName=request.getParameter( "stuName ");
String classes=request.getParameter( "classes ");
StuInfo student=new StuInfo();
student.setStuNo(stuNo);
student.setStuName(stuName);
student.setClasses(classes);
if(student.insertStu()){
System.out.println( "学生插入成功! ");
getServletContext().getRequestDispatcher( "/mlogin?password=admin&username=admin ").forward(request,response);
}
out.close();
}
javabean的:
public boolean insertStu() {
boolean bl = false;
status = "学生添加失败 ";
cb = new ConnectBean();
cb.openConnection();
/*if (!cb.openConnection()) {
status = "连接数据库失败!!! ";
}*/
&n