我希望我的代码能够做到这一点......
<c:if test="${validated != 'Y' }">
<form:form id="newJob" method="post" action="updateValidated" commandName="jobModel">
<form:input path="regattaId" type="hidden" />
<form:input path="job_id" type="hidden" />
<table>
<tr>
<td><spring:message code="label.validated" />
<td><form:radiobutton path="validated" value="Y" />Yes<form:radiobutton
path="validated" value="N" />No</td>
</tr>
</table>
<input type="submit" class="button" value='<spring:message code="label.validateJob"/>' hidden="true" />
</form:form>
</c:if>
<c:else>
This job is validated
</c:else>
任何接受者?现在它不起作用。 我认为我的语法是正确的,但我很新
答案 0 :(得分:3)
<c:else>
不存在,从未存在过。阅读您正在使用的内容the documentation,而不是尝试随机内容。
使用JSTL的正确方法是使用等于if / else的
<c:choose>
<c:when test="condition">...</c:when>
<c:otherwise>...</c:otherwise>
</c:choose>
答案 1 :(得分:2)
等效代码是
<c:choose>
<c:when test="${validated != 'Y' }">
<form:form id="newJob" method="post" action="updateValidated"
commandName="jobModel">
<form:input path="regattaId" type="hidden" />
<form:input path="job_id" type="hidden" />
<table>
<tr>
<td><spring:message code="label.validated" />
<td><form:radiobutton path="validated" value="Y" />Yes<form:radiobutton
path="validated" value="N" />No</td>
</tr>
</table>
<input type="submit" class="button"
value='<spring:message code="label.validateJob"/>' hidden="true" />
</form:form>
</c:when>
<c:otherwise>
This job is validated
</c:otherwise>
</c:choose>
Jstl的c:if标签没有伴随c:else标签。试试c:选择!