My linux world » Java Spring – SiteMesh

Java Spring - SiteMesh


Please read : Java spring – quickstart


If you use maven, add this to your pom.xml


Update WebConfig to add sitemesh filter

public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
    protected Filter[] getServletFilters() {
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        return new Filter[] { characterEncodingFilter, new ConfigurableSiteMeshFilter()};

Now ./src/main/webapp/WEB-INF/sitemesh3.xml :

    <mapping path="/*" decorator="/WEB-INF/decorators/layout.jsp"/>

Now ./src/main/webapp/WEB-INF/decorators/layout.jsp :

<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html>
<sitemesh:write property='head'/>
    <div id="content">
        <sitemesh:write property='body'>Body goes here.</sitemesh:write>

Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.

Fork me on GitHub