我知道我应该在配置文件或我自己的ConfigurableSiteMeshFilter
. 例如:
public class SitemeshFilter extends ConfigurableSiteMeshFilter {
@Override
protected void applyCustomConfiguration(final SiteMeshFilterBuilder builder) {
builder.addDecoratorPath("/*", "/WEB-INF/views/layouts/default.jsp");
}
}
这对我有用,但这并不完美。我可以直接在 JSP 文件中定义要使用的装饰器吗?
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html sitemesh:decorator="layouts/default.jsp"> <!-- something like this -->
<head>
<title>Home</title>
<meta content="test" name="description" />
</head>
<body>
<h1>Hello world!</h1>
${body}
</body>
</html>