学了一点点lervlet的入门知识可以简单校验网页提交过来的数据拿到mysql里面进行对比
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
String name = req.getParameter("sname");
String password = req.getParameter("password");
String newpassword = req.getParameter("newpassword");
String sex = req.getParameter("sex");
String[] aihao = req.getParameterValues("aihao");
System.out.println(name);
System.out.println(password);
System.out.println(newpassword);
System.out.println(sex);
try {
Test000 tt = new Test000();
boolean cha = tt.cha(name);
if (cha) {
System.out.println("创建成功");
// res.getWriter().println("创建成功");
} else {
// res.getWriter().println("创建失败");
System.out.println("创建失败");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
|
|