The Implement of Web Applications Based on Struts & Hibernate & Spring

The Implement of Web Applications Based on Struts & Hibernate & Spring

International Conference on Network and Finance Development, NFD 2010 The Implement of Web Applications Based on Struts & Hibernate & Spring Bin Pan 1, Qingzhong Dang 1, Tao Zhu 1, Bo Lai 2 1 College of Information Management, Chengdu University of Technology, Chengdu, China 2 Linkage Technology Co. Ltd, Nanjing, China Email: [email protected] Abstract: This paper takes college reference room management system for example, proposes the rapid de- velopment method which is based on architecture technology of Struts, Spring and Hibernate (SSH), and pre- sents the procedure of design and development during the course of Web information system. Result proves that, the SSH framework could reduce the development time of complex business systems, enhance the main- tainability and scalability of the systems also. Keywords: web applications; rapid development; Struts technology; Spring technology; Hibernate technology 1 Introduction grated perfectly, and have advantage in management of transaction dependence. The foundation of architecture is Currently, the web applications based on B/S model are the IOC container based on Bean property. Spring mainly sub-divided into five layers: user layer, presentation layer, processes the application business logic, business valida- business layer, persistence layer and database layer [1]. tion and transaction management, and manages the ob- However, the traditional development mode has no ready ject dependence in business layer as well. tools corresponding with the layers to quickly develop a Hibernate is an O/R (Persistence object/relationship) web application with clear hierarchy. In recent years, there mapping framework, complete with common Java ob- are three mature technologies in the J2EE platform based jects, carried out the lightweight package of JDBC, thus on MVC pattern: they provide rapid development tools of can display the data of object graph to the UI layer in different levels in web systems [2]. The Struts, Hibernate case of the database is disconnected, these data can be and Spring (SSH) technology framework, which integrated send back to the data persistence layer and update to the with Struts, Spring and Hibernate, not only improve the database. efficiency of system development, but also the security, In general, the method of integration with three frame- stability and robustness of system. work is to take Struts framework as the foundation ar- 2 SSH Framework chitecture of overall system (complete the separation of MVC), use Hibernate framework to support the persis- SSH framework is welcomed by the developer for its tence layer, and use Spring to support the business layer lightweight, open source and agile development sup- [4-5]. ported, it is the Abbreviation of Struts + Spring + Hiber- nate [3]. SSH integrate effectively the three architectures 3 System Design Based on SSH together, the hierarchical structure is clear, and avoids 3.1 Design of System high level of coupling in a single frame structure, thus it is easier to maintain and expand a system. With the growing of college enrollment, colleges more In the SSH framework, web layer is mainly realized and more type and quantity of information need to be with the Struts. The Struts just is a MVC framework stored. The overall target of system development is to based on JSP Model2, which could simplify the devel- achieve the systematization, standardization, information opment of web layer, achieve the separation of presenta- and automation management of college reference room, tion logic and data, and reduce the time of development. finally, improve the efficiency of data management, and Spring framework and Struts framework can be inte- reduce the workload. 311 978-1-935068-12-9 © 2010 SciRes. International Conference on Network and Finance Development, NFD 2010 3.1.1 The Analysis of Business Process Presentation layer: the Views are some JSP pages. The After analyze the business process of reference room data is indicated with ActionForm, the Controller com- management, the system mainly complete the staff in- bines with Action Servlet, Struts2 configuration file and formation management, book information management, Action classes. lending information management, etc... Figure 1 present Business Layer: achieve the business method and in- the general business process of system. terfaces of the system, which are formed with some Java Staff information classes and JavaBean. The core business logic is pack- aged into JavaBean, as well as the interactive relationship Staff infor- Personal between Hibernate. Staff mation information information management Persistence layer: mainly implement the object/ rela- Reader Admin tionship mapping, using Hibernate's own database con- Book infor- Book Book mation information list nection pool technology. management Database layer: use the Oracle to manage the applica- Book information tion data. Admin User layer Lending Browser Credentials information Lending Reader management information (View)JSP pages (Controller)Servlet Presentation layer (Struts) Lending information Action Form Figure 1. The business process diagram of system Business Layer Struts ActionServlet (Model)JavaBean (Struts+Spring) 3.1.2 Design of Function Modules Persistence layer Data access objects Persistence objects According to the analysis of business and data flow, the (Hibernate) main of system are shown in Figure 2. Oracle 10g Database layer Reference room management system Figure 3. The system architecture System Reference Search man- Statistics 3.2 Implement of System management management agement management In system development process, take MyEclipse 6.5 as Lending information Lending Article management Article Grade management Grade Paper management Paper Achievements Sta- Achievements Book management Book User management User File management information Staff Lending search Lending Article search search Article Log Statistics Statistics Log Paper search search Paper search Book development tool, the database system choose Oracle tistics 10g. Complete the SSH integration of three framework with configuration file. When deploy the web server, use Linux operating system, and the Tomcat6.0 as service software. Figure 2. The function structure of system Firstly, achieve the basic Java object according to the UML models of system, and then complete the basic DAO interface, use DAO classes of Hibernate frame- 3.1.3 Design of System Architecture The system includes five levels, which is shown in Fig- work to implement the mapping and access between Java ure 3. classes and the database. Finally, complete the business User layer: treatment the interaction of the user with logic with Spring. the client browser, including JSP and HTML pages. 3.2.1 Presentation Layer Presentation layer is responsible for processing the re- 978-1-935068-12-9 © 2010 SciRes. 312 International Conference on Network and Finance Development, NFD 2010 quest and data transfer between the client and the busi- < property name ="StatisticDAO"> ness layer. The layer achieved by Struts framework, < ref local ="StatisticDAO"> < / ref > mainly include the JSP pages, ActionForm, Action, Ac- < / property > tion Servlet and Struts2config. Xml. </bean> The settings of "Statistics condition check" action in … Struts2config. Xml file is as follows: <!-Configure the methods of transaction management --> < action path ="/ StatVoiceAction" <aop: config> input ="/news/ StatRule. jsp" <aop: pointcut id="StatisticMethod" type ="org.spring framework.web.struts. expression="execution(*.Statistic*"/> DelegatingActionProxy" <aop: advisoradvice-ref="txAdvice" name ="NewsActionForm" pointcut- ref="StatisticMethod"/> parameter ="methode" </aop: config> scope ="request" (Other code slightly) validate ="true" Spring configure the SessionFactory and Hiber- < / action > nateTemplate with the configuration file, in order to … achieve dependency injection of Hibernate resources. In <!-- Log Statistics function --> configuration file, the search for resources such as JDBC <include DataSource and Hibernate SessionFactory is defined as file="com/linkage/trtbs/action/querystat/queryStat.xml different Bean, the application objects could access the " /> resources only through reference by the corresponding <!—Chart display of Log Statistics--> Bean [5]. <include 3.2.3 Persistence Layer file="com/linkage/trtbs/action/ querystat/chart/log_chart.x Firstly, create the persistent classes and mapping through ml"> an XML format mapping described file to achieve the </include> objects map as database tables, the relationships map as (Other code slightly) the relationship between tables. The suffix of the docu- 3.2.2 Business Layer ment is entitled “hbm.xml”. It is necessary to create con- At first, create the management classes for each function figuration profile as “Hibernate.cfg.xml”. The code fol- module to manage and maintain its business logic, and lowing is part of configuration file of the system. then modify the of Spring, register the bean class corre- <session-factory> sponding to the manage class, to meet their transaction <!—ORACLE access setting--> control with AOP mode. The example configurations file <property of transaction management as follows: name="connection.username">developer</property> < ! - -Configure sessionFactory - - > <property name="dialect"> <bean id="sessionFactory" org.hibernate.dialect.Oracle9Dialect</property> class="*.LocalSessionFactoryBean"> <property name="connection.driver_class"> <property name="configLocation"></property> oracle.jdbc.driver.OracleDriver</property>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us