For design references to previous entity classes my previous blog: http://blog.csdn.net/u013082989/article/details/50983650
The project file has been put on GitHub and you are welcome to Follow,star.Address:Https://github.com/lawlite19/SmartEducation
One: Extract Baseaction (1) First say the use of modeldriven, such as user login, I want to get interface input user account usernum and user password password, you can declare in the action class and implement the Get, set method, Corresponds to the Name property of the interface input, and then you can get(You can also declare a user user object in the action, which corresponds to the attribute write User.usernum,user.password to the interface input)
Useafter Modeldriven, the Name property in the interface corresponds to the property of the object
You can declare an object model directly in the class and get the properties of the object by using the Model.get () method.
(2) Extract the Baseaction class, first of all why to extract, because we in each action to define the corresponding object model, we can extract out declared as generics, by reflection to get the type of the object.
There is a service interface object that may be reused in each action, and we also declare the interface object used in Baseaction as the protected type (just a few days ago, a second-interview C + +, a review of the relationship between classes), You can get the service interface object of the parent class as long as you inherit baseaction.
Two: Call code optimization on the DAO layer(1) because before we in the Basedao the public to increase, delete, change, check out the code, you can refer to my blog after the note: http://blog.csdn.net/u013082989/article/details/ 50964133 And because our service layer is often called toAdd, delete, change, check, so the service layer again to write again, and then to call the DAO layer, so repeat (of course, no problem), we now put the business Layer service and the DAO layer together, the Basedao renamed to Daosupport, Service layer inherits Daosupport can
The DAO layer is not needed.
Querying the database directly at the service layer through the GetSession () method(GetSession is in Daosupport, declared as protected type, can be obtained in subclasses)
(2) After the optimized diagram:
Java EE SSH Framework baseaction extraction and other aspects of code optimization