【问题标题】:Tiles 3 and Spring 3 integration throwing exceptionTiles 3 和 Spring 3 集成抛出异常
【发布时间】:2013-08-17 18:51:32
【问题描述】:

我正在尝试集成 Spring 3 和 Tiles 3,我正在查看页面并且应用程序运行良好,但它给了我以下错误。 javax.servlet.ServletException: File "/WEB-INF/template/WEB-INF/template/layout.jsp" not found

这是我的配置文件。

<bean class="org.springframework.web.servlet.view.tiles3.TilesViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.tiles3.TilesView"></property>
    <property name="order" value="0"></property>
</bean>
<bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"
    id="tilesConfigurer">
    <property name="definitions" value="/WEB-INF/tiles.xml"></property>
</bean>
<bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:I18N/messages" />
    <property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>
<mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/" />
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="lang"></property>
        </bean>
    </mvc:interceptor>
</mvc:interceptors>

这是我的tiles.xml

<tiles-definitions>
<definition name="base.definition"
    template='WEB-INF/template/layout.jsp'>
    <put-attribute name="title" value="" />
    <put-attribute name="header" value="/WEB-INF/tile/header.jsp" />
    <put-attribute name="body" value="" />
    <put-attribute name="footer" value="/WEB-INF/tile/footer.jsp" />
</definition>

<definition name="login" extends="base.definition">
    <put-attribute name="title" value="login" />
    <put-attribute name="body" value="/WEB-INF/tile/login.jsp" />
</definition>

这是我的 layout.jsp

<body bgcolor="">
<table border="1" cellpadding="2" cellspacing="2" align="center">
    <tr>
        <td height="20%" colspan="1"><tiles:insertAttribute
                name="header" /></td>
    </tr>
    <tr>
        <td width="350"><tiles:insertAttribute name="body" /></td>
    </tr>
    <tr>
        <td height="10%" colspan="1"><tiles:insertAttribute
                name="footer" /></td>
    </tr>
</table>

我在这里做错了什么? 我花了几个小时,仍然无法弄清楚。

【问题讨论】:

  • 尝试将WEB-INF/template/layout.jsp 更改为layout.jsp
  • 在这种情况下 layout.jsp 的位置应该是什么。是否必须与 WEB-INF 平行移动。

标签: spring spring-mvc tiles-3


【解决方案1】:

查看异常:

javax.servlet.ServletException: File &quot;/WEB-INF/template/WEB-INF/template/layout.jsp&quot; not found

Tiles 尝试在 /WEB-INF/template/WEB-INF/template 中查找“layout.js”。

<definition name="base.definition"
    template='WEB-INF/template/layout.jsp'>

尝试在模板路径前加“/”:

<definition name="base.definition"
    template='/WEB-INF/template/layout.jsp'>

【讨论】:

  • 一开始是这样的,但我遇到了一个更严重的错误。它多次渲染我的图块并导致堆栈溢出。
  • 请在您的问题中添加 layout.jsp 和其他页面以获得更多信息
  • 我添加了layout.jsp,请查看
  • 一切看起来都很好。试一试:尝试删除具有空值(标题和正文)的 put-attribute。如果出现“属性未定义”异常,请使用 ignore="true" 属性:。改变之后 - 仍然是无限循环和堆栈溢出?
猜你喜欢
  • 2013-01-28
  • 1970-01-01
  • 1970-01-01
  • 2017-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多