Better alternative to Apache Tiles

前端 未结 5 644
北恋
北恋 2020-12-18 19:52

I\'m looking for a framework that is better and easier to use than Apache Tiles (which so far, I have used a couple of times).

With Tiles, it seems that when I have

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 20:38

    Overall, I would recommend SiteMesh over Tiles.

    Here's how to setup SiteMesh 3

    You can use Tiles for in-page templates, but use SiteMesh for site-wide template. Nevertheless...

    How to make Tiles suck less:

    1. Use convention over configuration. For example, put your definitions in webapp/WEB-INF/tiles.xml and there's no need to tell tiles where it is.

    2. Use wildcards:

    
        
        
    
    
    
        
        
    
    

    If your controller returns view name index, it will match the definition *, and use the JSP file /WEB-INF/views/index.jsp for the body, and use the message property index.title.

    If your controller returns view name contact-us, it will match the definition *, and use the JSP file /WEB-INF/views/contact-us.jsp for the body, and use the message property contact-us.title

    In your template, add:

    
    

    and

    <spring:message code="${titleKey}"/>
    

    Add ReloadableResourceBundleMessageSource bean to your servlet application context.

    Make a file /src/main/resources/messages.properties, with content like:

    index.title = Welcome to Acme, Inc.
    contact-us.title = Contact Us
    

提交回复
热议问题