错误org.apache.tiles.TilesException:找不到属性 [英] Error org.apache.tiles.TilesException: Attribute not found

查看:94
本文介绍了错误org.apache.tiles.TilesException:找不到属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Web项目,并且我使用Tiles在一个JSP中具有多个JSP.

I'm working on a web project and I use Tiles to have multiple JSP's in one JSP.

我遇到了 TilesIOException 的问题.

我有一个名称为 mainpage.jsp 的JSP,其中包含所有JSP的页眉,正文和页脚.

I have this JSP with the name: mainpage.jsp which contains all the JSP's for header, body and footer.

我的身体中还应该包含其他一些JSP,因此我也尝试在其中使用瓦片,但没有运气.

My body here should also contain some other JSP's and therefore I'm trying to use tiles in that as well with no luck.

以下是图块中的结构和XML代码:

Here's the structure and the XML code in tiles:

mainpage.jsp
----header.jsp
----body.jsp(mainpageBody.jsp)
--------bodybox1.jsp
--------bodybox2.jsp
--------bodybox3.jsp
--------bodybox4.jsp
----footer.jsp

tiles.xml :

tiles.xml:

<definition name="mainpage" extends="mainpageLayout">
<put-attribute name="title" value="Welcome" />
<put-attribute name="body" value="/mainpage/mainpageBody.jsp" />
    <put-attribute name="mainbox0" value="/bodybox1.jsp" />
    <put-attribute name="mainbox1" value="/bodybox2.jsp" />
    <put-attribute name="mainbox2" value="/bodybox3.jsp" />
    <put-attribute name="mainbox3" value="/bodybox4.jsp" />
</definition>

<definition name="mainpageLayout" template="/mainpage.jsp">
<put-attribute name="title" value="Template" />
<put-attribute name="header" value="/mainpage/header.jsp" />
<put-attribute name="body" value="/mainpage/body.jsp" />
<put-attribute name="footer" value="/mainpage/footer.jsp" />
</definition>

这是我的 mainpageBody.jsp :

Here is my mainpageBody.jsp:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ page import="java.text.*,java.util.*"%>

<script type="text/javascript">
    function showRegisterUserPage() {
        $(".frontpageBodyContent").load("showRegisterPageRegisterAction");
    }
</script>
<div class="frontpageBodyContent">
    <div id="frontPageContentDiv">
        <table border="0" style="width:100%">
            <tbody>
                <tr>
                    <td>
                        <div id="bodybox1">
                            <tiles:insertAttribute name="bodybox1" />
                        </div>
                    </td>
                    <td>
                        <div id="bodybox2">
                            <tiles:insertAttribute name="bodybox2" />
                        </div>
                    </td> 
                </tr>
                <tr>
                    <td>
                        <div id="bodybox3">
                            <tiles:insertAttribute name="bodybox3" />
                        </div>
                    </td>
                    <td>
                        <div id="bodybox4">
                            <tiles:insertAttribute name="bodybox4" />
                        </div>
                    </td> 
                </tr>
            </tbody>
        </table>
    </div>
</div>

WEB-INF 文件夹包含: lib 文件夹, tiles.xml & web.xml . lib 文件夹不包含任何内容.

WEB-INF folder contains: lib folder, tiles.xml & web.xml. lib folder doesn't contain anything.

struts.xml :

struts.xml:

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
    <constant name="struts.enable.SlashesInActionNames" value="true"/>
    <constant name="struts.action.extension" value=",action"/>
    
    <package name="default" extends="struts-default">
        <result-types>
            <result-type name="tiles"
                class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>
        
        <action name="*MainAction" method="{1}" class="com.x.web.action.MainAction">
            <result name="mainpage" type="tiles">mainpage</result>
            <result name="success">index.jsp</result>
        </action>
        
        <action name="*RegisterAction" method="{1}" class="com.x.web.action.RegisterAction">
            <result name="registeruserpage" type="tiles">registeruserpage</result>
            <result name="redirect" type="redirect">${redirectUrl}</result>
        </action>
    


    <action name="registrering" method="showRegisterUserPage" class="com.x.web.action.RegisterAction">
        <result name="registeruserpage" type="tiles">registeruserpage</result>
    </action>

</package>

web.xml :

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:javaee="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <javaee:display-name>X</javaee:display-name>
    <context-param>
        <javaee:param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
        </javaee:param-name>
        <javaee:param-value>/WEB-INF/tiles.xml</javaee:param-value>
    </context-param>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <javaee:listener-class>org.apache.struts2.tiles.StrutsTilesListener
        </javaee:listener-class>
    </listener>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

我遇到例外情况

org.apache.tiles.TilesException :

ServletException including path '/templates/mainpage.jsp'.

org.apache.tiles.util.TilesIOException: JSPException including path '/content/mainpage/mainpageBody.jsp'.

org.apache.tiles.TilesException: Attribute 'bodybox1' not found.

我在做什么错了?

推荐答案

尝试以下 web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>X</display-name>

    <listener>
        <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
    </listener>
    <context-param>
        <param-name>tilesDefinitions</param-name>
        <param-value>/WEB-INF/tiles.xml</param-value>
    </context-param>
        <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

,并检查 WEB-INF 文件夹中的 tiles.xml .

这篇关于错误org.apache.tiles.TilesException:找不到属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆