0

ここで同様の問題が尋ねられました。デフォルトの名前空間が指定されていない場合、関数 "" は接頭辞とともに使用する必要があります。しかし、私の文脈は異なります。

コントローラーから (補助クラスを使用して) 作成されたオブジェクトの配列リストを取得する jsp を含む Spring Web アプリがあり、これらのオブジェクト値はテーブルにレンダリングされます。私のコントローラー、Jspページ、およびヘルピングクラスは次のとおりです

コントローラ

public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    /**
     * Simply selects the home view to render by returning its name.
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
        public String home( Model model) {
            logger.info("Welcome home! the client locale is ");




            ArrayList<TrendSign> ts=new ArrayList<TrendSign>();
             for(int i=0;i<5;i++)
             {
                TrendSignDAO actor = new TrendSignDAO();
                actor.setPhrase("phrase"+i);
                actor.setHitCount(i);
                 actor.setWordCount(i);
                 actor.setCharCount(i);
                 ts.add(actor);
             }

            model.addAttribute("ts", ts );

            return "home";
    }

}

JSPページは次のとおりです。

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
    <html>
    <head>
        <title>Home</title>
        </head>
    <body>
        <table border=1>
            <thead>
                <tr>
                    <th>Phrase</th>
                    <th>hit count</th>
                    <th>wordcount</th>
                    <th>char count</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach var="row" items="${ts}">
                    <tr class="odd gradeX">
                         <td><c:out value="${row.getPhrase()}"/></td>
                         <td><c:out value="${row.getHitCount()}"/></td>
                         <td><c:out value="${row.getWordCount()}"/></td>
                         <td><c:out value="${row.getCharCount()}"/></td>
                    </tr>
                </c:forEach>
        </tbody>
    </table>
    </body>
</html>

お手伝いクラス

public class TrendSign {

 private String phrase;
 private int hitCount;
 private int wordCount;
 private int charCount;

 public void setPhrase(String phrase)
 {
     this.phrase = phrase;
 }
 public String getPhrase()
 {
     return (this.phrase);
 }
 public void setHitCount(int hitCount)
 {
     this.hitCount = hitCount;
 }
 public int getHitCount()
 {
     return (this.hitCount);
 }
 public void setWordCount(int wordCount )
 {
     this.wordCount = wordCount;
 }
 public int getWordCount()
 {
     return (this.wordCount);
 }
 public void setCharCount(int charCount )
 {
     this.charCount = charCount;
 }
 public int getCharCount()
 {
     return (this.charCount);
 }


public TrendSignDAO() {
    // TODO Auto-generated constructor stub
     this.phrase = "Phrase";
     this.hitCount = 5;
     this.wordCount = 1;
     this.charCount = 1;
}

}

これは私のローカル ホスト (Java 6 Tomcat 6) で正常に動作しますが、jelastic (Java 6 Tomcat 6) にデプロイすると、エラー WEB-INF/views/home.jsp(26,8) が表示されます 関数 getPhrase を使用する必要がありますデフォルトの名前空間が指定されていない場合のプレフィックス。jelastic の Web アプリにアクセスするための URL はhttp://lovedmusic.jelastic.servint.net/です。誰でもこれをデバッグする方法を教えてもらえますか?

4

1 に答える 1

2

DAO は DAO のようには見えませんが、JSP-EL を使用すると、メソッド構文なしでゲッターにアクセスできるはずです。プロパティ名を使用するだけです:

<td><c:out value="${row.phrase}"/></td>    
<td><c:out value="${row.hitCount}"/></td>
<td><c:out value="${row.wordCount}"/></td>
<td><c:out value="${row.charCount}"/></td>
于 2013-04-23T05:27:52.547 に答える