1

struts2 と spring フレームワークを使用してプロジェクトを作成しました。現在、タイル フレームワークを使用して動的コンテンツを分離しようとしています。レイアウトは、ヘッダーと本文で構成されます。ヘッダーには Welcome xyz (ログインしたユーザーの名前) が含まれ、本体部分には、起動時にデータベースから入力された表形式のリストが含まれています。

以下は私のタイルレイアウトコードです

Layout.jsp

<body>
<tiles:insertAttribute name="header"/>
<tiles:insertAttribute  name="body"/>
</body>

tiles.xml

<tiles-definitions>
    <definition name="baseLayout" template="layout.jsp">
        <put-attribute name="header" value="welcome.jsp"/>
        <put-attribute name="body" value=""/>
    </definition>
    <definition name="addToListLayout" extends="baseLayout">
        <put-attribute name="body" value="addEmployee.jsp"/>
    </definition>
</tiles-definitions>

しかし、ログイン後、jspで次の出力が得られます:-


Welcome.jsp addEmployee.jsp


コンテンツではなくjspの名前を取得している理由を誰か教えてもらえますか?

4

1 に答える 1

1

The issue is that tiles is not interpreting your attributes as templates, it is interpreting them as strings. From the tiles doc:

This tag can be flexibly used to insert the value of an attribute into a page. As in other usages in Tiles, every attribute can be determined to have a "type", either set explicitly when it was defined, or "computed". If the type is not explicit, then if the attribute value is a valid definition, it will be inserted as such. Otherwise, if it begins with a "/" character, it will be treated as a "template". Finally, if it has not otherwise been assigned a type, it will be treated as a String and included without any special handling.

So you can change your tag in tiles.xml to either this:

<put-attribute name="header" value="/welcome.jsp"/>

or this:

<put-attribute name="header" type="template" value="welcome.jsp"/>
于 2012-05-29T04:27:42.207 に答える