我試圖從頭開始編寫我的第一個Java Bean + JSP頁面。但是,我用它填充了任意值的二維數組,現在我得到一個例外,當我運行JSP說,數組屬性不能被發現:
JSP Exception: javax.el.PropertyNotFoundException: Property 'utilTableVals' not found on type diskUtil.tester
這裏是我的bean代碼:
package diskUtil;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.*;
import java.lang.*;
import java.io.*;
public class tester{
//public String [][] utilTableVals;
String [][] utilTableVals = new String[20][20];
/***
bean's properties accessor
***/
/*public String[][] getUtilTableVals() {
return utilTableVals;
}*/
public static String[][] getUtilTableVals()throws Exception{
tester du1 = new tester();
//String [][] utilTableVals = new String[20][20];
int i=0;
int j=0;
int row=0;
int col=0;
int result=0;
for(int r = 0; r < du1.utilTableVals.length; r++)
{
for(int c = 0 ; c < du1.utilTableVals[r].length; c++)
{
result = r+c;
du1.utilTableVals[r][c]=Integer.toString(result);
//System.out.print(" " + utilTableVals[r][c]);
}
}
return du1.utilTableVals;
}//end getUtilTableVals
我的JSP代碼是在這裏:
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<hmtl>
<head>
<title>Disk Utilization Page</title>
</head>
<body>
<h1>DISK UTILZATION REPORT</h1>
<br>
<jsp:useBean id="diskUtilData" scope="request" class="diskUtil.tester" />
<table>
<c:forEach var="celldata" items="${diskUtilData.utilTableVals}">
<tr>
<c:forEach var="col" items="${celldata}">
<td>
<c:out value="${col}" />
${col}
<p>hello</p>
</td>
</c:forEach>
</c:forEach>
</tr>
</table>
</body>
</html>
可能有人請看看?提前致謝。
-TU
謝謝大家。我得到它的工作! – 2011-06-06 22:31:33