春の MVC プロジェクトとタイル 3 でいくつかの問題に直面しています。主な問題の 1 つはリスト属性に関するものです。私が作ろうとしているのは、究極のビューの記事のOptionsRenderer
ように、を使用して一般的なタイル定義を作成することです(lit 属性が定義の外で定義されているため、記事に誤りがあります)。式を使用していくつかの属性を作成すると、このリスト属性を定義したにもかかわらず、その名前のリスト属性が見つからないため、テンプレート JSP で常に が取得されます。私のコードは次のとおりです。${options[myoptions]}
IllegalStateException
myoptions
tiles.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="WILDCARD:*/*" template="/WEB-INF/view/template.jsp">
<put-attribute name="meta" value="/WEB-INF/view/${options[folder]}/meta.jsp" />
<put-attribute name="header" value="/WEB-INF/view/${options[folder]}/header.jsp" />
<put-attribute name="body" value="/WEB-INF/view/${options[folder]}/{2}.jsp" />
<put-attribute name="footer" value="/WEB-INF/view/${options[folder]}/footer.jsp" />
<put-list-attribute name="folder">
<add-list-attribute>
<add-attribute value="{1}" />
<add-attribute value="common" />
</add-list-attribute>
</put-list-attribute>
</definition>
</tiles-definitions>
template.jsp
<%@ page language="java" pageEncoding="UTF-8"
contentType="text/html; charset=utf-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<title>${dynamicTitle} - <fmt:message key="common.siteName" /></title>
<tiles:insertAttribute name="meta" />
</head>
<body>
<div id="header">
<tiles:insertAttribute name="header" />
</div>
<div id="body">
<tiles:insertAttribute name="body" />
</div>
<div id="footer">
<tiles:insertAttribute name="footer" />
</div>
</body>
</html>
いくつかの解決策を試しましたが、結果はありませんでした。私の試行は次のとおりです。 1.<tiles:importAttribute name="folder"/>
私の JSP で使用します。まったく違いはありません 2.<tiles:insertAttribute name="folder"/>
私の JSP で使用します。属性が文字列ではないため、例外が発生しました。3.<tiles:putListAttribute name="folder">FULL_DEFINITION_HERE</tiles:putListAttribute>
違いをまったく使用せずに JSP で属性を定義します。
上記の記事と、タイルのドキュメント、特にOptionsRenderer のドキュメントを参照しましたが、役に立ちません。ここで私が間違っていることを誰か教えてもらえますか? これはSpring MVCとは関係ないと思います。