In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail the example analysis of SSH+Jquery+Ajax framework integration. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Desired effect:
Click submit on the login page for background verification
Verify the successful jump to index.Jsp
If the verification fails, execute a jQuery script to prompt the user on this login page.
Required package:
In addition to the packages used by SSH2, the following packages of struts2 are required:
Commons-beanutils-1.8.0.jar
Commons-collections-3.1.jar
Commons-fileupload-1.3.1.jar
Commons-io-2.2.jar
Commons-lang-2.4.jar
Commons-lang3-3.1.jar
Commons-logging-1.1.3.jar
Ezmorph-1.0.6.jar
Freemarker-2.3.19.jar
Json-lib-2.3-jdk15.jar
Ognl-3.0.6.jar
Struts2-core-2.3.16.3.jar
Struts2-json-plugin-2.3.16.3.jar
Xwork-core-2.3.16.3.jar
All right, start posting the code:
Login.jsp
Members log in to $(document) .ready (function () {$("# button"). Click (function () {varuser = $("# User"). Val (); varpassWord = $("# PassWord"). Val (); $.ajax ({/ / the name attribute of the Struts.xml required here is the same. Url:'login.action', / / submit type type:'POST', / / submit data to Action input data data: {'User':user,'PassWord':passWord}, / / returned data type dataType:'json' / / success is the method called success:function (data) {/ / get the data returned by Action and use the attribute name in data.Action to get if (data.result== "false") {alert ("account password error") } elseif (data.result== "true") {/ / do page jump, because ajax our Action only returns data, not jump. Location.href = "index.jsp";});})
Account number:
Password:
LoginAction.java
Publicclass LoginAction extends ActionSupport {/ / injection condition attribute name using @ Resource annotation must be consistent with ref @ Resource FUserService fUserServiceImp; @ Resource FUser fUser; private String User; private String PassWord; private String result; public String getResult () {returnresult;} publicvoid setUser (String User) {this.User = User;} publicvoid setPassWord (String PassWord) {this.PassWord = PassWord;} public String execute () throws Exception {HttpServletRequest request = ServletActionContext.getRequest () / / the data sent by ajax can be obtained directly by using the attribute name of the foreground. FUser.setUserEmail (User); fUser.setUserPassWord (PassWord); if (fUserServiceImp.CheckUser (fUser)! = null) {/ / data returned to ajax this.result = "true";} else {this.result = "false";} return "success";}}
Struts.xml
Other SSH2 framework integration does not need to change so that the jQuery framework ajax can be integrated into the SSH2 framework to use!
This is the end of this article on "sample Analysis of SSH+Jquery+Ajax Framework Integration". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.