如何在jsp标记文件中使用if语句

时间:2015-08-27 15:59:06

标签: html jsp jsp-tags

我有.tag文件:

#block-yui_3_17_2_17_1431527054679_7625 .sqs-gallery-block-grid element.style {
    margin-left: 0px;
    margin-right: 0px;
    padding-left: 0px;
    padding-right: 0px;
   max-width: 100%;
}

.content-inner {
    background-color: #fff;
    max-width: 100%;
    margin: 0 auto;
    padding: 100px 8%;
   padding-left: 0px;
    padding-right: 0px;

}

我想显示变量“job.prio” - 变量,只是在“job.status”等于“open”的情况下。 这意味着,如果“job.status”不是“打开”,则“Prio:”之后不会显示任何内容。

我尝试了这个,但它不起作用..

<%@tag description="Displays reduced information for analysis jobs" pageEncoding="ISO-8859-1"%>
<%@attribute name="job" required="true" type="redb.main.core.model.AnalysisJob"%>

<div class="analysis-job-reduced" data-job-id="${job.id}">
<p><span class="job-id">Job ${job.id}</span>: <span class="status">${job.status}</span></p>
<p class="prio">Prio: ${job.prio}</p>
<p class="executive">${job.executive.name}</p>
<p class="waiting-for">Waiting for ${job.textWaitingFor}</p>

非常感谢你的帮助!

1 个答案:

答案 0 :(得分:0)

以下是有效的代码:

<div class="analysis-job-reduced" data-job-id="${job.id}">
<p><span class="job-id">Job ${job.id}</span>: <span class="status">${job.status}</span></p>
<%-- <p class="prio">Prio: ${job.prio}</p> --%>
<c:choose>
    <c:when test="${job.status == 'open'}">
        <p class="prio">Prio: ${job.prio}</p>
    </c:when>
    <c:otherwise>
        <p class="prio">Prio: Job is not open anymore</p>
    </c:otherwise>
</c:choose>
<p class="executive">${job.executive.name}</p>
<p class="waiting-for">Waiting for ${job.textWaitingFor}</p>