在我的项目中,我想使用Sitemesh,每个页面都有一个菜单模板。以前,他在web.xml
工作。但是现在我删除了web.xml
,并且我想在没有web.xml
的情况下实现它。正确地实现了站点网格,对我来说不起作用
package adil.java.schoolmaven.config;
import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
public class MySiteMeshFilter extends ConfigurableSiteMeshFilter {
@Override
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
builder.addDecoratorPath("/*", "/WEB-INF/decorators/homeDecorator.jsp")
.addDecoratorPath("/allStudents", "/WEB-INF/decorators/homeDecorator.jsp")
.addDecoratorPath("/addStudents.jsp", "/WEB-INF/decorators/addStudentDecorator.jsp");
}
}
我删除的web.xml中的代码
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>