我有list一些包含一些对象.对象有一个hours字段.
在<c:foreach>我迭代列表并获取对象.
现在我想总结hours一个totalHours变量中所有迭代对象的字段.
我的代码:
<c:forEach var="attendance" items="${list }" varStatus="rowCounter1">
<tr>
<td><c:out value="${rowCounter1.count}"></c:out></td>
<td><c:out value="${attendance.date }"></c:out></td>
<td><c:out value="${attendance.inTime }"></c:out></td>
<td><c:out value="${attendance.outTime }"></c:out></td>
<td><c:out value="${attendance.interval }"></c:out></td>
<c:set var="totalHours" value="${attendance.Hours += attendance.Hours }"
target="${attendance}"</c:set>
</tr>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
我试过这个,但它给了我以下错误:
javax.el.ELException: Failed to parse the expression [${attendance.Hours += attendance.Hours }
Run Code Online (Sandbox Code Playgroud) Write an efficient algorithm to print the following two outputs
Run Code Online (Sandbox Code Playgroud)
您将获得一个名为getrand100()的预定义函数,该函数返回一个整数,该整数是1-100中的一个随机数.您可以根据需要多次调用此函数,但要注意此函数是非常耗费资源的.您不能使用任何其他随机生成器.您无法更改getrand100()的定义.
int getrand100(){
Random rand = new Random();
return (1+rand.nextInt(100));
}
Run Code Online (Sandbox Code Playgroud)
注意: