如何评估 Struts <s:if test> 标签中的 JSP scriptlet 变量?

问题描述 投票:0回答:1

jsp中无法处理空指针异常。我想要如果下面的值为 null 则获取值 0,否则为值

<td width="30%">${ms:doubleTOInteger(requestScope.topActivityList[count.index].totalScore)} </td>

如果 count.index = 0 那么它工作正常 对于其他值,它返回 null(值为 0,1,2)

我尝试添加 if else 条件,但没有成功。

<%
if(request.getAttribute("topActivityList[count.index]") == null){
String token = new String("asd");
}
%> 
<s:if test="token =='asd'">
<td width="30%" >${token}</td>
</s:if>
<s:else>                                                
<td width="30%">${ms:doubleTOInteger(requestScope.topActivityList[count.index].totalScore)} </td>
    </s:else>
jsp struts
1个回答
0
投票

之前更改了“doubleTOInteger”的自定义代码,但现在我已经更改了 java 代码

© www.soinside.com 2019 - 2024. All rights reserved.