Home > Article > Web Front-end > Ajax verify user uniqueness
This article mainly introduces the uniqueness of Ajax verification users and the verification environment Ajax Jquery Json struts2. Interested friends can refer to it
For beginners, learn the practical practice of Ajax verification of user uniqueness It is to consolidate the basic knowledge of Ajax, Jquery, Json and Struts2. The specific content is as follows
Browse the renderings:
Operation steps are as follows
1. First, we import the required packages and files Json package:3. Then, start writing our login.jsp page, of course you can add some CSS styles to it to make it more beautiful. (I only did it briefly, a bit low)struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2 /*
4. Then, we started writing Action.
Ajax+Jquery验证用户的唯一性
//验证用户的唯一性 public void isexist() throws IOException { boolean exist = name.equals("张三") ; JSONObject result=new JSONObject(); if(exist){ result.put("exist", true); }else{ result.put("exist", false); } ServletActionContext.getResponse().setContentType("text/html;charset=utf-8"); PrintWriter out=ServletActionContext.getResponse().getWriter(); out.println(result.toString()); out.flush(); out.close(); }5. Finally, write the Struts.xml file
The above is me I compiled it for everyone, I hope it will be helpful to everyone in the future. Related articles:/login.jsp
How Ajax calls the restful interface to transmit Json format data (with code)
Boa server Ajax and cgi communication under (graphic tutorial)
Ajax Struts2 implements verification code verification function (graphic tutorial)
The above is the detailed content of Ajax verify user uniqueness. For more information, please follow other related articles on the PHP Chinese website!