The traditional struts development framework uses CodeWritten in action, the transaction logic is configured to query data in the service, so there is a design defect:
1: if there are many database operations, you need to write a long amount of code in the service.
2: Some database operations are related to the Business Code level. The judgment and other operations are indispensable between two database operations. Therefore, some business logic is written in the service layer and some in the Action layer, which is confusing.
Therefore, is there a way to extract Business Code to one level? Considering the different framework structures, it is found that the required operations are basically as follows:
1. submit data (or Ajax)
2. Assemble data (struts assembles form parameters to actionform)
2. Start the transaction
3. Identify database exceptions and business logic throws business or database exceptions to return
4. End the transaction
5. Assemble data to return (struts uses formbean and request to carry objects, while AJAX can be XML or other definition formats)