启动项目时,网格站点在web.xml中工作。但是现在我想在没有web.xml的情况下运行它,我删除了他。我写的代码似乎是正确的,但是您可以知道在哪里出错或编写不正确。 他没有向我显示sitemesh菜单模板
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", "/WEB-INF/decorators/addStudentDecorator.jsp");
}
}
Servlet初始化程序
public class ServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Value("${spring.servlet.multipart.max-file-size}")
private int maxFileSize;
@Value("${spring.servlet.multipart.max-request-size}")
private int maxRequestSize;
@Autowired
private Environment environment;
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[]{HibernateConfig.class/*, SecurityConfig.class*/};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[]{WebMvcConfig.class};
}
@Override
protected String[] getServletMappings() {
return new String[]{"/"};
}
@Override
protected Filter[] getServletFilters() {
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
return new Filter[]{characterEncodingFilter, new SiteMeshFilter()};
}
}