How to use hibernate in jsp that comes to mind by tile

Source: Internet
Author: User
Since learning jsp, it has been affected by the MVC2 mode. It may have been a bit more chance to write code before. Few page items. Therefore, I have always felt that jsp pages have always been the first choice for development. In this way, functions, code, and pages can be separated. In addition, as I am just working, I am still in the theoretical> practical stage. Therefore, we recommend a standardized design in the project. MVC is required for everything. During this time, I learned tile. It seems that this is not a simple way to prepare data for action, and then launch a jsp development method. It seems that the tile control function has destroyed the push mode.
You can use the control function to pull data from the jsp page. For example, a userlist operation. If tile is not used, the data may be read in the action and then encapsulated into the actionform for display on the jsp page. After tiles is used, you can use a tiles control to read the required data from the database in jsp. In this way, it can be more flexible, and nothing should be included in the actionForm. What if there is no corresponding data in actionForm during page adjustment? Although we recommend that you use coarse-grained design for the actionForm design, you cannot make any changes to your business.
Maybe it's a small project, so pay special attention to development efficiency. To facilitate and flexibly pull out the required data on the page. Instead of writing too many scripts or tiles control, it defines a label for running HQL. In this way, you can directly run HQL on the page, and hand over all the cache, migration, performance, and SQL to Hibernate for processing. In this way, it can be maximized to play the role of Hibernate. The tag design uses the <bean: define/> method and attributes in Struts as follows:
--- Run an HQL ---
<Page: hibernate id = "test" hql = "from com. cms. model. TbaseEnumlist"
Page = "2" pagesize = "4">
Result size:
// Directly use the script variables defined by <page: hibernate>
<% = Test. size () %> <br>
// Use the struts label to operate the pageContext attribute defined by <page: hibernate>.
<Logic: iterate id = "element" name = "test" type = "com. cms. model. TbaseEnumlist">
<Bean: write name = "element" property = "enumcode"/> <br>
</Logic: iterate>
</Page: hibernate>
--- Load a PO ---
<Page: hibernate id = "test" type = "com. cms. model. TbaseEnumlist" primary = "15">
Enumeration name:
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.