This is the framework used for my first project at the company, so I have tried to build it myself. In fact, it is similar to the three frameworks.
This is the package structure of our company. You can understand the package structure. The configuration file jdbc. properties is used to access the database configuration in spring.
Log4j is a log configuration file, which indicates the wrong information and where to write the accessed information.
The sqlMapConfig configuration file is the total configuration file of ibatis. What is written below is the mapping configuration file, which is placed in the same location as the entities package. One configuration is written for each package.
If you want to query multiple tables, you need to create another class, and insert the attributes used in the two tables into this class.
Spring-config: Several configuration files of spring are put under the folder.
One write is the creation of action, the other is the creation of biz layer, and the DAO
In fact, struts actions can be created using spring, and a sentence is added.
<Constant name = "struts. objectFactory" value = "spring"/>
After the package structure is configured, web. xml is configured.
It is to tell tomcat which are the struts configuration files and spring configuration files, so that tomcat can be created when it is started.
<? Xml version = "1.0" encoding = "UTF-8"?>
<Web-app xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: web = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id = "WebApp_ID" version = "2.5">
<Display-name> HD_U </display-name>
<Context-param>
<Param-name> webAppRootKey </param-name>
<Param-value> HD_U.root </param-value>
</Context-param>
<Listener>
<Listener-class> org. springframework. web. util. Log4jConfigListener </listener-class> // Add a log listening class
</Listener>
<Listener>
<Listener-class> org. springframework. web. context. ContextLoaderListener </listener-class> // spring listening class
</Listener>
<Context-param>
<Param-name> log4jConfigLocation </param-name> // The initialization parameter of the log class listener, which indicates where the configuration file is located.
<Param-value> classpath: log4j. properties </param-value>
</Context-param>
<Filter>
<Filter-name> struts2 </filter-name> // single controller of struts2
<Filter-class> org. apache. struts2.dispatcher. FilterDispatcher </filter-class>
</Filter>
<Filter-mapping>
<Filter-name> struts2 </filter-name>
<Url-pattern>/* </url-pattern>
</Filter-mapping>
<Context-param>
<Param-name> contextConfigLocation </param-name> // The spring listening class tells the spring configuration file where
<Param-value> classpath *:/spring-config/applicationContext *. xml </param-value>
</Context-param>
<Welcome-file-list>
<Welcome-file> index.html </welcome-file>
</Welcome-file-list>
<Servlet>
<Description> </description>
<Display-name> InitServlet </display-name>
<Servlet-name> InitServlet </servlet-name>
<Servlet-class> com. hdu. web. common. InitServlet </servlet-class>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
</Web-app>