A scheme for the combination of Java Web Development Framework __web

Source: Internet
Author: User
Tags java web

Struts2+ibatis+json realization of Fast Java web2.0 program development

With Struts2 basically finished a company project, the program is always summed up after the development, the previous scheme is STRUTS2+SPRING+DWR these three kinds of framework of the combination of the database operation of the spring in the JdbcTemplate, Always to hibernate do not like, previously in Hibernate 2 when using it total reported out of the memory error, may H3 performance is better than 2, but in essence it is the database operation of the SQL encapsulated, the user's control is limited, Trying to write a special SQL is too much trouble, so I've been using JdbcTemplate.

Last week, the leader asked to start the next project as soon as possible development work, although according to the old framework of the development is familiar, but still let the brothers in the group to study whether there is a faster way to work, the current technical research results are Struts2+ibatis+json, abandoned the DWR, with an ORM , using the JSON plug-in to achieve AJAX effects. The code file combinations for previous scenarios are:

1. An STRUTS2 action class that writes the definition of several row beans in the spring configuration file, and writes several row configurations in Struts2.

2. A DAO interface, a DAO implementation class, an entity bean definition, a spring configuration file that writes several rows of datasource injection, and a transaction configuration.

3. A DWR class that handles Ajax, as well, writes several row configuration parameters in spring, writes several lines in the Dwr.xml file

4. Several JSP files at the front desk

In order to save trouble, there is no separate business processing class, in the Struts2 action to do business logic processing, so even a basic with Ajax effect of the CRUD operation page will be 5 Java files and a number of JSP files, XML configuration parameters at least 8 rows or so, The Division of the layer from the thought that it is clear, development efficiency in general.

Now when you do the new project, you will use a struts2+ibatis+ajax+json combination, ibatis with a for Eclipse plug-in, DAO interface, implementation class, entity class, and configuration parameters directly generated, The most important is Ibatis operation database when the SQL statement can control, extract the first n rows, sorting, paging, etc. directly in the write SQL on the line, powder cool, see the programmer magazine Introduction, Taobao is also using Ibatis, there is a certain truth.

OK, now the database operation layer of things basically do not spend too much energy to knock code, and then look at the Ajax operation of this layer, used to DWR framework, this time to remove DWR, directly with STRUTS2, Server end with Struts2 Jsonplugin, Action can directly return the results of JSON format to the foreground presentation layer, the front desk casually use Prototypejs or dojo or simply write a dozens of-line Ajax request JS class to process the JSON data.

Now to do a data display, Ibatis directly returns a list containing the entity class lists, struts2 configured JSON return format to the front desk, the foreground processing JSON data display, simple, my boys do this research or do a good job, pagination, database query conditions and so on a little encapsulation of the effect is very good.

When you edit the data, the foreground directly submits the data to the action through JSON, the action directly to the entity class, do not need to go from the request object to manually take what things, the data submitted to have been filled into the entity class, and then use Ibatis to handle database operations, Wow, Cool.

Of course, now do not write spring configuration parameters or not, this is still more annoying, no technical content, data entry errors are not a hint, can only be seen when running.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.