如何使用c:当条件在输入标签的值属性内时?

时间:2022-07-21 20:33:22

how to use c:when condition inside value attribute of input tag?

如何使用c:当条件在输入标签的值属性内时?

<input id="textid" type="button" value="">

in the 'value'. what I want is

在“价值”。我想要的是

<c:when test="${texttest == 'Y'}"> Add </c:when>
<c:otherwise> Edit </c:otherwise>

Value should be 'Add' if textest is 'Y' otherwise 'Edit'

如果textest是" Y "则值应该是" Add "否则" Edit "

2 个解决方案

#1


2  

<input id="textid" type="button" value="${texttest == 'Y' ? 'Add' : 'Edit'}">

#2


0  

<c:choose>
<c:when test="${texttest == 'Y'}">
 Add 
</c:when>
<c:otherwise>
 Edit 
</c:otherwise>
</c:choose>

#1


2  

<input id="textid" type="button" value="${texttest == 'Y' ? 'Add' : 'Edit'}">

#2


0  

<c:choose>
<c:when test="${texttest == 'Y'}">
 Add 
</c:when>
<c:otherwise>
 Edit 
</c:otherwise>
</c:choose>