0

次の属性を持つオブジェクトのリストがあります

public class ViewTestCasesBean {

private String testcaseName;
private String subject;
private String description;
private List<TestCaseDetailsBean> testList = new ArrayList<TestCaseDetailsBean>();

// GETTERS AND SETTERS SECTION.......///////

public String getTestcaseName() {
    return testcaseName;
}

public void setTestcaseName(String testcaseName) {
    this.testcaseName = testcaseName;
}

public String getSubject() {
    return subject;
}

public void setSubject(String subject) {
    this.subject = subject;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public List<TestCaseDetailsBean> getTestList() {
    return testList;
}

public void setTestList(List<TestCaseDetailsBean> testList) {
    this.testList = testList;
}

}

今、私のアクションコードは...

   public String execute() {


    detailsList = viewTestCasesTransaction.fetchTestCases();
    session.put("testcaseList", detailsList);

    if (detailsList.size() > 0) {

        return SUCCESS;
    }
    return ERROR;
}

ここで detailsList は、表示タグで表示される上記オブジェクトのリストです。

私は以下で試しました

 <jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="urn:jsptld:http://java.sun.com/jstl/core">
<%@page import="org.apache.jasper.tagplugins.jstl.core.Import"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*"%>
<%@ page import="com.harmony.cloud.bean.TestCaseDetailsBean"%>
<%@ page import="com.harmony.cloud.action.ViewTestCasesAction"%>

<%@ page import="java.sql.*"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>

<html>
   <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

 <title>Test Cases List</title>


  </head>
   <body>
<%session.getAttribute("testcaseList"); %>
<display:table name="detailsList" id="parent">
    <display:column property="testcaseName" />
    <display:column property="subject" />
    <display:column property="description" title="Comments" />

    <c:set var="nestedName"
        value="detailsList[${parent_rowNum -1}].testcaseList}" />
 <display:table  name="${nestedName}" id="child${parent_rowNum}" >
    <display:column title="Steps">
</display:table>
</display:column>

  <display:setProperty name="paging.banner.placement" value="top" />

        </display:table>

  </body>
</html>

しかし、次のエラーが発生しました........

org.apache.jasper.JasperException: /testCasesView.jsp (行: 3、列: 3) 要素のコンテンツは、整形式の文字データまたはマークアップで構成されている必要があります。org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher. java:89) org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:207) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:226) org.apache.jasper.compiler.ParserController. parseDirectives(ParserController.java:119) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:193) org.apache.jasper.compiler.Compiler.compile(Compiler.java:373) org.apache.jasper. compiler.Compiler.compile(Compiler.

コーディングの何が問題になっていますか?

4

2 に答える 2

0

次の要素に注意してください。

1)<jsp:root ...>終了タグがありません

2)値式には、中括弧とクラス属性testcaseListが存在しないため、次<c:set var="nestedName" value="detailsList[${parent_rowNum -1}].testcaseList}" />のように変更します。<c:set var="nestedName" value="detailsList[${parent_rowNum -1}].testList" />

3)display:ネストされたテーブルの列タグにproperty属性がありません<display:column title="Steps">

4)ファイルの最初の行にdoctypeを配置します<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

5)これは単なる質問です。セッション属性を取得していますが、割り当てていません。これはわざとですか?

displaytag-examples-1.2.war-> example-nestedtables.jspからの例

于 2013-01-02T17:40:11.263 に答える
0

Eclipse IDE を使用している場合は、JSP を作成するときに、ウィザードに従って html マークアップまたは xhtml マークアップを使用して JSP を作成します。JSP 2.0 固有のタグ、xhtml マークアップを使用して JSP を作成したくない場合。Project -> new -> JSP File -> Use JSP Template -> New JSP File with xhtml/html markup にチェックを入れます。

于 2013-03-13T08:35:21.600 に答える