Finally, I have finished this test. I hope it will be helpful for beginners who want to learn struts.
(Mystruts application) directory structure
Mystruts
|-WEB-INF
|-Lib
|-Struts. jar
|-Classes
|-ConnectionPool
|-GetDbConnection. class
|-Mystruts
|-User1Action. class
|-UserAction. class
|-UserActionForm. class
|-Userdao. class
|-Struts-bean.tld
|-Struts-config.xml
|-Struts-html.tld
|-Struts-logic.tld
|-Struts-template.tld
|-Adduser. jsp
|-Index. jsp
|-Viewuser. jsp
Step 1: configure the development environment
(If you do not have any software, please download it from http://www.apache.org)
Tomcat5.0 configuration (create a mystruts application and copy relevant files)
Find the confCatalinalocalhost subdirectory in your tomcat installation directory. Create the mystruts. xml file.
The file content is as follows. In this file, we will configure a connection pool. Change the relevant driver, database user, and password to your own local configuration.
Copy the JDBC driver to the Tomcat 5.0 commonlib directory. Put struts. jar mystrutsWEB-INFlib directory.
<Context path = "/mystruts" docBase = "D: wwwmystrutsmystrutsmystruts" debug = "0" privileged = "true">
<Resource name = "jdbc/TestDB"
Auth = "Container"
Type = "javax. SQL. DataSource"/>
<ResourceParams name = "jdbc/TestDB">
<Parameter>
<Name> factory </name>
<Value> org. apache. commons. dbcp. basicperformancefactory </value>
</Parameter>
<Parameter>
<Name> maxActive </name>
<Value> 10 </value>
</Parameter>
<Parameter>
<Name> maxIdle </name>
<Value> 5 </value>
</Parameter>
<Parameter>
<Name> maxWait </name>
<Value> 10000 </value>
</Parameter>
<Parameter>
<Name> username </name>
<Value> sa </value>
</Parameter>
<Parameter>
<Name> password </name>
<Value> test </value>
</Parameter>