Max*_*axI 2 java jsp jstl exception
我有一个问题非常类似于这个堆栈溢出问题JSP没有在bean中查找属性.还有这个问题javax.el.PropertyNotFoundException:在类型com.example.Bean上找不到属性'foo'.然而在我的情况下,我认为我已经完成了所有的书籍,我仍然得到一个错误. 下面是我的javabean代码片段的一部分
private double otheramount;
private int no;
private String name;
public double getOtherAmount()
{
return otheramount;
}
public void setOtherAmount(double newotheramount)
{
otheramount = newotheramount;
}
public int getNo()
{
return no;
}
public void setNo(int newno)
{
no = newno;
}
public String getName()
{
return name;
}
public void setName(String newname)
{
name = newname;
}
Run Code Online (Sandbox Code Playgroud)
以下是我的DAO代码的一部分
while(rs.next())
{
MyBean mybean = new MyBean();
mybean.setNo(rs.getInt("No"));
mybean.setName(rs.getString("Full_Names"));
mybean.setOtherAmount(rs.getDouble("OtherAmount"));
allresults.add(mybean);
}
Run Code Online (Sandbox Code Playgroud)
下面是servlet代码的一部分
try
{
ArrayList allresults = mydao.search();
request.setAttribute("allresults",allresults);
RequestDispatcher dispatch =request.getRequestDispatcher("Pages/mypage.jsp");
dispatch.forward(request, response);
}
catch(Exception ex)
{
}
Run Code Online (Sandbox Code Playgroud)
下面是我在JSP页面中的HTML和JSTL代码
<c:forEach var="results" items="${requestScope.allresults}">
<tr>
<td><c:out value="${results.no}"></c:out></td>
<td><c:out value="${results.name}"></c:out></td>
<td><c:out value="${results.otheramount}"></c:out></td>
</tr>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
问题是,当我评论该部件时,<c:out value="${results.otheramount}"></c:out>它运行正常并且不会抛出任何错误.但是,取消注释此部分会导致找不到属性的错误.作为旁注,财产otheramount后来添加了很多.
我正在使用Netbeans 7.1.2.任何帮助非常感谢.
Bean属性名称不基于私有字段名称解析.相反,它们是基于getter方法名称解析的.
在您的特定情况下,属性名称不是otheramount,但它是otherAmount.
| 归档时间: |
|
| 查看次数: |
1826 次 |
| 最近记录: |