2

STS で単純な Roo プロジェクトを作成しました。テンプレートと思われるいくつかの .jspx ファイルが作成されました。それらに HTML と CSS を配置できるようにしたいのですが、重要なものを変更すると例外が発生します。たとえば、基本的な HTML を追加すると、次のようになります。

<div><span><p>Hello</p></span></div>

私はこの例外を受け取ります:

SEVERE: Servlet.service() for servlet [msa] in context with path [/msa] threw exception [Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/layouts/default.jspx'.] with root cause
org.apache.jasper.JasperException: /WEB-INF/views/homepage/index.jspx (line: 14, column: 6) The content of elements must consist of well-formed character data or markup.

または、コントローラーから取得したリストをループする必要があるとしましょう。

<c:forEach var="announcement" items="${results}">
                    <option value ="10"><c:out value="${announcement.author}"/></option>
</c:forEach>

次に、この例外が発生します。

SEVERE: Servlet.service() for servlet [msa] in context with path [/msa] threw exception [Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/layouts/default.jspx'.] with root cause
org.apache.jasper.JasperException: /WEB-INF/views/homepage/index.jspx (line: 12, column: 54) The prefix "c" for element "c:forEach" is not bound.

このテンプレート ファイルに単純な変更を加えるのがなぜそれほど難しいのか、私にはわかりません。かなりの検索を行った後、.jspx ファイルの構文は .jsp ファイルの構文とは異なり、手動編集には推奨されないことがわかりました。代わりに .jsp ファイルを使用するように Roo を構成するにはどうすればよいですか? これは可能ですか?

編集:ファイル全体の例を次に示します。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" xmlns:util="urn:jsptagdir:/WEB-INF/tags/util" version="2.0">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <jsp:output omit-xml-declaration="yes"/>
  <spring:message code="label_homepage_index" htmlEscape="false" var="title"/>
  <util:panel id="title" title="${title}">
    <spring:message code="application_name" htmlEscape="false" var="app_name"/>
    <h3>
      <spring:message arguments="${app_name}" code="welcome_titlepane"/>
    </h3>

    <div><span><p>Hello</p></span></div>

    <c:forEach var="announcement" items="${results}">
                        <option value ="10"><c:out value="${announcement.author}"/></option>
    </c:forEach>

    </util:panel>
</div>

最初の例をコメントアウトして、2 番目の問題を確認できます。しかし、問題は実際にはこれらの特定のケースではなく、テンプレートで通常の HTML を使用できないため、ページの作成がはるかに困難になります。どうすればそれを回避できますか?

4

1 に答える 1

1

Regarding your first example, it seems like you may have put your stuff in the wrong place. Maybe paste the whole file (it's short) so we can see if there's actually an error.

In the second example, the exception says "The prefix "c" for element "c:forEach" is not bound.". That usually means your xmlns prefix probably isn't declared in the jspx header.

于 2013-01-03T14:51:32.740 に答える