本文介绍了无法呈现不是字符串的属性,toString返回:在SPRING MVC中为空ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下教程为我的spring mvc项目创建一个通用的错误处理程序:

I am trying to create a generic error handler for my spring mvc project by following this tutorial: http://www.mkyong.com/spring-mvc/spring-mvc-exceptionhandler-example/

但在我的项目,我使用tiles-defs,当我访问浏览器中的错误页面时,我收到此错误:

But In my project, I am using tiles-defs and I am getting this error when I access the error page in the browser:

org.apache.tiles.request.render.CannotRenderException: Cannot render an attribute that is not a string, toString returns: null
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:255)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:397)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:238)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:221)
at org.apache.tiles.renderer.DefinitionRenderer.render(DefinitionRenderer.java:59)
at org.springframework.web.servlet.view.tiles3.TilesView.renderMergedOutputModel(TilesView.java:114)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:267)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1217)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1005)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:952)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

这里是我的tile-defs配置:

Here is my tiles-defs configuration:

    <definition name="/error/generic_error">
    <put-attribute name="body" value="/WEB-INF/views/error/generic_error.jsp" />
    <put-attribute name="browserTitle" value="Error Screen" />
    </definition>

我找不到原因和解决方案,所以任何帮助将不胜感激。

I can't find the cause nor the solution for this problem so any help would be much appreciated.

推荐答案

您需要在tile定义中添加基本模板。它应该扩展一个模板,或者您必须提及您的定义的路径属性< definition name =/ error / generic_errorpath ={your-path}>

You need to add the base template in your tiles definition. It should either extend a template or you must mention the path attrib at your defintion <definition name="/error/generic_error" path= "{your-path}">

这篇关于无法呈现不是字符串的属性,toString返回:在SPRING MVC中为空ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 05:26