Announcement Announcement Module
Collapse
No announcement yet.
Spring MVC - Layout solution Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC - Layout solution

    I'd like to create layout solution in combination with Spring MVC, Web Flow, Security, Data, etc...

    What I've found:

    1. VelocityLayoutViewResolver - possible but I don't like it because in JSP is taglib "spring:" I like so much
    2. Apache Tiles 2 - possible, but I've not really found any usable example how to combine it with JSP

    What I think it should do:

    1. Define default layout in bean config
    2. Override layout in @Controller or @RequestMapping
    3. Simple use

    I'd like to have template like this:

    layout.jsp
    HTML Code:
    <!-- Should be placed in place for example like WEB-INF/views/layout.jsp -->
    <html>
        <head>
            <title> <c:out value="${page_title}"> </title>
        </head>
        <body>
            <div header />
            <div content-wrapper>
                <%@include file="${view_name}"%>
            </div content-wrapper>
            <div footer />
        </body>
    </html>
    @Controller
    Code:
    @Controller
    public class PersonController {
    
        @RequestMapping("/")
        public String index(Map<String, Object> map) {
    
            // this will mark included view path, can be configurable through prefix/suffix in bean declaration
            // layout will be for example in path: WEB-INF/views/person/index.jsp
            return "person/index.jsp";
        }
    
    }
    What solution do you think I should use?
    Thanks

  • #2
    Go for tiles. I suggest the tiles website and the tiles reference guide/documentation. It has some samples and tutorials.

    Regarding your controller I suggest only returning person/index to decouple it from the actual view layer.

    Comment

    Working...
    X