Recently learned the integration of SSH2 (Struts2+spring+hibernate), began to try to write a landing interface, the results found: If you just use Struts2 to page jump, the effect of the page is not good, but also can not be local refresh (that is, asynchronous commit validation).
So, I began to search for solutions on the Internet, some say through a hidden iframe to achieve the effect, when I always feel trouble and not practical. Later asked the teacher, told me to use Ajax to achieve the desired effect, I found there are many examples of the internet is Ajax, but the lack of SSH2 (integrated) and AJAX integration (Ajax using the jquery framework).
Tell me about the effect I want:
Login Page Click Submit after the background verification;
Validation successfully jumps to index. JSP;
Validation fails to execute a jquery script on this login page to prompt the user;
Required Packages:
In addition to the packages used by SSH2, the following packages are required for struts2:
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
OK, start the code:
login.jsp
Struts.xml
<?xml version= "1.0" encoding= "UTF-8"? > <struts> <!- This is the package --> <package name= "struts" extends= to configure struts when we configure SSH Struts-default "> <action name=" Login "class=" LoginAction " > </action> </package> <!-to allow Ajax to invoke action in spring to configure Ajax package --> < Package name= "Ajax_json" extends= "Json-default" > <!-the ID of this place is ajax The value of the URL, class refers to the id--> <action of the spring configuration action Name= "Login" class= "loginaction" > <result name= "Success" type= "JSON"/> < /action> &nbsP; </package></struts>
Other SSH2 framework integration does not need to be changed so that the jquery framework of Ajax integration into the SSH2 framework to use!
The above content personal remarks, if there is something wrong, please pay attention to ... I will try to correct!
Well, I wish you all a happy!
This article is from "Lazy cat" blog, please be sure to keep this source http://lazycat0102.blog.51cto.com/8938702/1587187
Ssh+jquery+ajax Wonderful Integration