Ajax verify user uniqueness

亚连
Release: 2018-05-24 09:55:01
Original
1572 people have browsed it

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:

Ajax verify user uniqueness

Ajax verify user uniqueness

Ajax verify user uniqueness

Ajax verify user uniqueness

##Then let’s get started,

Operation stepsare as follows

1. First, we import the required packages and files

Json package:

Ajax verify user uniqueness

struts2 package:

Ajax verify user uniqueness

Introduce jquery-2.1.1.min .js files.

Copy after login

2. Then, we need to configure the Struts2 filter in the web.xml file

 struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter   struts2 /* 
Copy after login

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)

Ajax+Jquery验证用户的唯一性

名字:



Copy after login

4. Then, we started writing Action.

//验证用户的唯一性 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(); }
Copy after login

5. Finally, write the Struts.xml file

  /login.jsp  
Copy after login

The above is me I compiled it for everyone, I hope it will be helpful to everyone in the future.

Related articles:

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!