Login and registration based on struts 2 and Hibernate

This example shares the login and registration functions of struts 2 and hibernate for your reference. The specific contents are as follows

1. The project uses the MySQL database. The database name is test and the table name is info, as shown in the figure:

2. Configure web XML (used by struts 2)

3. Write view components (JSP pages)

(1) Login page login jsp

(2) Login success page jsp

(3) Registration page register jsp

4. Business controller action

(1) The business controller corresponding to the login page loginaction java

Among them, override the valiadate () method for manual verification

(2) The business controller registeraction corresponding to the registration page java

5. In struts Configure action in XML

6. Hibernate configuration file

To use hibernate, you need to load the database driver and establish a connection with the data through the hibernate configuration file. The configuration file is hibernate cfg. xml

7. Load the class of Hibernate configuration file above (hibernatesessionfactory. Java)

8. Po object and corresponding mapping file (under the same package)

(1) Class of Po object userinfopo Java

(2) Map file corresponding to Po userinfopo hbm. xml

9. Complete login and registration business functions

Encapsulate the login and registration business functions into the class loginregisterinfo (JavaBean)

Database operation class loginregisterinfo java:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>