AJAX实现注册验证用户名(ajax实现用户注册功能的方法)难以置信

随心笔谈1年前发布 编辑
160 0


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.io.IOException;

@WebServlet(“/findName”)
public class FindNameServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding(“utf-8”);
response.setContentType(“text/html;charset=utf-8”);
String name=request.getParameter(“name”);
UserDao userDao=new UserDaoImpl();
User name1=userDao.findName(name);
if (name1!=null){
response.getWriter().write(“1”);
}else {
response.getWriter().write(“2”);
}
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
}

© 版权声明

相关文章