Table of Contents
Ajax+Jquery验证用户的唯一性
名字:
Home Web Front-end JS Tutorial Ajax verify user uniqueness

Ajax verify user uniqueness

May 24, 2018 am 09:55 AM
ajax uniqueness verify

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 steps are 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.

<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
Copy after login

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

<filter>
 <filter-name>struts2</filter-name>
 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
 </filter>
 <filter-mapping>
 <filter-name>struts2</filter-name>
 <url-pattern>/*</url-pattern>
 </filter-mapping>
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)

<p class="row">
 <h1 id="Ajax-Jquery验证用户的唯一性">Ajax+Jquery验证用户的唯一性</h1>
 <form action="" method="post">
  <h3 id="名字">名字:</h3>
  <input type="text" id="name" class="form-control" name="user.name" id="name" placeholder="请输入你的用户名">
  <br><br>
  <input type="submit" class="btn btn-success" value="验证用户的唯一性"/>    
  <span id="namemsg"></span>
 </form>
</p>
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

<package name="user" namespace="/" extends="struts-default">  
 <action name="user_*" class="com.ddge.action.UserAction" method="{1}">
  <result name="error">/login.jsp</result>
 </action>
</package>
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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to verify signature in PDF How to verify signature in PDF Feb 18, 2024 pm 05:33 PM

We usually receive PDF files from the government or other agencies, some with digital signatures. After verifying the signature, we see the SignatureValid message and a green check mark. If the signature is not verified, the validity is unknown. Verifying signatures is important, let’s see how to do it in PDF. How to Verify Signatures in PDF Verifying signatures in PDF format makes it more trustworthy and the document more likely to be accepted. You can verify signatures in PDF documents in the following ways. Open the PDF in Adobe Reader Right-click the signature and select Show Signature Properties Click the Show Signer Certificate button Add the signature to the Trusted Certificates list from the Trust tab Click Verify Signature to complete the verification Let

Detailed method to unblock using WeChat friend-assisted verification Detailed method to unblock using WeChat friend-assisted verification Mar 25, 2024 pm 01:26 PM

1. After opening WeChat, click the search icon, enter WeChat team, and click the service below to enter. 2. After entering, click the self-service tool option in the lower left corner. 3. After clicking, in the options above, click the option of unblocking/appealing for auxiliary verification.

How to solve the 403 error encountered by jQuery AJAX request How to solve the 403 error encountered by jQuery AJAX request Feb 20, 2024 am 10:07 AM

Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

How to solve jQuery AJAX request 403 error How to solve jQuery AJAX request 403 error Feb 19, 2024 pm 05:55 PM

jQuery is a popular JavaScript library used to simplify client-side development. AJAX is a technology that sends asynchronous requests and interacts with the server without reloading the entire web page. However, when using jQuery to make AJAX requests, you sometimes encounter 403 errors. 403 errors are usually server-denied access errors, possibly due to security policy or permission issues. In this article, we will discuss how to resolve jQueryAJAX request encountering 403 error

New features in PHP 8: Added verification and signing New features in PHP 8: Added verification and signing Mar 27, 2024 am 08:21 AM

PHP8 is the latest version of PHP, bringing more convenience and functionality to programmers. This version has a special focus on security and performance, and one of the noteworthy new features is the addition of verification and signing capabilities. In this article, we'll take a closer look at these new features and their uses. Verification and signing are very important security concepts in computer science. They are often used to ensure that the data transmitted is complete and authentic. Verification and signatures become even more important when dealing with online transactions and sensitive information because if someone is able to tamper with the data, it could potentially

PHP and Ajax: Building an autocomplete suggestion engine PHP and Ajax: Building an autocomplete suggestion engine Jun 02, 2024 pm 08:39 PM

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

How to solve the problem of jQuery AJAX error 403? How to solve the problem of jQuery AJAX error 403? Feb 23, 2024 pm 04:27 PM

How to solve the problem of jQueryAJAX error 403? When developing web applications, jQuery is often used to send asynchronous requests. However, sometimes you may encounter error code 403 when using jQueryAJAX, indicating that access is forbidden by the server. This is usually caused by server-side security settings, but there are ways to work around it. This article will introduce how to solve the problem of jQueryAJAX error 403 and provide specific code examples. 1. to make

How to get variables from PHP method using Ajax? How to get variables from PHP method using Ajax? Mar 09, 2024 pm 05:36 PM

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

See all articles