Home > Article > Web Front-end > jQuery+Ajax authenticates users
This time I will bring you jQuery Ajax user verification. What are the precautions for jQuery Ajax user verification? The following is a practical case, let’s take a look.
Insert title here
LoginServlet
public class LoadServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 解决乱码 request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); // 1.得到用户名 String username = request.getParameter("username"); // 2.判断用户名是否可以使用 if ("tom".equals(username)) { // 用户名不可以使用 response.getWriter().write("用户名被占用"); } else { // 用户名可以使用 response.getWriter().write("用户名可以使用"); } } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
web.xml
LoadServlet LoadServlet com.zxl.servlet.LoadServlet LoadServlet /load
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
How to use android and HTML mixed development
How to use the new attribute display:box of css
The above is the detailed content of jQuery+Ajax authenticates users. For more information, please follow other related articles on the PHP Chinese website!