Spring Boot 2 + JSP + Tiles的示例

时间:2018-10-20 21:50:17

标签: spring-boot tiles

我正在尝试使用Spring Boot 2 + JSP + Tiles用户,但是页面未加载并引发异常,请问有人知道如何解决此问题吗?感谢任何帮助,谢谢

以下代码段。

@Configuration
public class WebConfiguration implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
    interceptor.setParamName("lang");
    registry.addInterceptor(interceptor);
    }

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
    registry.enableContentNegotiation(new TilesView(), new JstlView());

    registry.tiles();

    registry.jsp("WEB-INF/jsp/", ".jsp");
    }

    @Bean
    public TilesConfigurer tilesConfigurer() {
    TilesConfigurer tiles = new TilesConfigurer();
    tiles.setDefinitions("file:src/main/webapp/WEB-INF/layout/default.xml");
    return tiles;
    }

}

例外

2018-10-20 22:35:21.992 DEBUG 28674 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] based on Accept header types and producible media types [*/*])
2018-10-20 22:35:26.663 DEBUG 28674 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Invoking afterPropertiesSet() on bean with name 'login'
2018-10-20 22:35:33.756 DEBUG 28674 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'metaDataSourceAdvisor'
2018-10-20 22:35:33.757 DEBUG 28674 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2018-10-20 22:35:33.757 DEBUG 28674 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'metaDataSourceAdvisor'
2018-10-20 22:35:33.757 DEBUG 28674 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2018-10-20 22:36:54.354 DEBUG 28674 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.web.servlet.view.tiles3.TilesView: unnamed; URL [null]] based on requested media type 'text/html'
2018-10-20 22:36:54.354 DEBUG 28674 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.web.servlet.view.tiles3.TilesView: unnamed; URL [null]] in DispatcherServlet with name 'dispatcherServlet'
2018-10-20 22:36:54.355 DEBUG 28674 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Error rendering view [org.springframework.web.servlet.view.tiles3.TilesView: unnamed; URL [null]] in DispatcherServlet with name 'dispatcherServlet'

java.lang.IllegalStateException: No Renderer set
    at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.view.tiles3.TilesView.renderMergedOutputModel(TilesView.java:135) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]

0 个答案:

没有答案