Problems encountered:
1: java.sql.SQLException: ORA-00913: too many values
Reason: Wrong sql statement, or the number of values is inconsistent with the format of the database table.
2: Always show that the user already exists
Reason: The service layer code is wrong, forget to add it! Causes a logical judgment error.
public boolean addStudent(Student student){
if(!studentDao.isExist(student.getSno())){
studentDao.addStudent(student);
return true;
}else{
System.out.println("此人已经存在!");
return false;
}
3: Generate garbled characters? ? ? ? ?
Reason: Only the encoding format of the request was set, which resulted in problems with the response and garbled characters.
request.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
//设置响应编码
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("utf-8");
if(result){
out.println("增加成功!");
}else{
out.println("增加成功!");
}
Still producing garbled characters? ? ? ?
Reason: the sequence is wrong: it should be set before the out object responds!
//设置响应编码
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
if(result){
out.println("增加成功!");
}else{
out.println("增加成功!");
}
4.
In the process of modifying the password according to the user name, I encountered the failure to update () to null
Reason: The new password is inconsistent with the parameters accepted in the servlet when the new password is retransmitted, which makes it impossible to add a new password, and the password column in the user table in the database is non-empty, which causes this phenomenon.
Overall structure process: