JSTL c:choose issue
I need to implement a switch case using JSTL choose statement, I have tree different choise. Anyone knows the reason why the code below doesn't work?
Thanks in advance.
<c:choose>
<c:when test="${iUserInfo.identification_card_type}==0">
<option selected="selected">Carta di Identità</option>
<option>Passaporto</option>
<option>Patente di Guida</option>
</c:when>
<c:when test="${iUserInfo.identification_card_type}==1">
<option>Carta di Identità</option>
<option selected="selected">Passaporto</option>
<option>Patente di Guida</option>
</c:when>
<c:when test="${iUserInfo.identification_card_typ开发者_如何学Ce}==2">
<option>Carta di Identità</option>
<option>Passaporto</option>
<option selected="selected">Patente di Guida</option>
</c:when>
<c:otherwise>
<option>Scegli...</option>
<option>Carta di Identità</option>
<option>Passaporto</option>
<option>Patente di Guida</option>
</c:otherwise>
</c:choose>
Because you didn't evaluate the entire expression inside ${}
. Fix it accordingly:
<c:when test="${iUserInfo.identification_card_type == 0}">
...
<c:when test="${iUserInfo.identification_card_type == 1}">
...
<c:when test="${iUserInfo.identification_card_type == 2}">
Ciao,
I usually use this kind of test:
test="${iUserInfo.identification_card_type eq 0}"
Instead of normal comparison you should use the jstl's ones, like gt (greater then), st (smaller then) and eq, that means equals. Keep going, jstl and servlet they rock!
精彩评论