Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Ajax verifies the uniqueness of users

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "Ajax how to verify the uniqueness of users", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Ajax how to verify the uniqueness of users" this article.

The details are as follows

Browse the effect picture:

Then here we go. The steps are as follows.

1. First of all, let's import the required packages and files.

Json package:

Struts2 package:

Import the jquery-2.1.1.min.js file.

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

Struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2 / *

3. Then, start writing our login.jsp page, of course, you can add some CSS style to it to make it more beautiful. (I just did it briefly, a little bit Low)

Ajax+Jquery verifies the unique name of the user:

4. Then we started writing Action.

/ / verify the uniqueness of the user public void isexist () throws IOException {boolean exist = name.equals ("Zhang San"); 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

/ login.jsp above is all the content of the article "how Ajax verifies the uniqueness of users". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report