`

org.apache.tiles.impl.InvalidTemplateException: Cannot render a null template

 
阅读更多

最近终于把spring MVC +Apache tiles整合了起来,但是在项目得运行期间报了一个Cannot render a null template错误:

 

具体错误如下:

 

2014-04-08 23:20:44  Could not complete request
org.apache.tiles.impl.InvalidTemplateException: Cannot render a null template
 at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:51)
 at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
 at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
 at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
 at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:594)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1365)
 at com.hailong.midea.web.filter.SessionFilter.doFilterInternal(SessionFilter.java:80)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:483)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
 at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:521)
 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
 at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
 at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
 at org.eclipse.jetty.server.Server.handle(Server.java:351)
 at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:451)
 at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:916)
 at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
 at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
 at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
 at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
 at java.lang.Thread.run(Thread.java:662)

 

解决方案:

原因是因为xxx-tiles.xml中模板定义没有继承导致的问题。

定义模板必须要extends="baseLayout" 继承父模板才行。否则重定向时将会报如上错误。

 

<!-- 信息提示页面 -->
 <definition name="tipsInfoView" extends="baseLayout">
  <put-attribute name="title" value="xxxx管理系统-系统提示"/>
  <put-attribute name="body" value="/WEB-INF/view/tips/common-tips.jsp"></put-attribute>
 </definition>

 

配置完成,重启即可。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics