Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp JSTL<;c:何时>;及<;选择>;标签_Jsp_Jstl_Jsp Tags - Fatal编程技术网

Jsp JSTL<;c:何时>;及<;选择>;标签

Jsp JSTL<;c:何时>;及<;选择>;标签,jsp,jstl,jsp-tags,Jsp,Jstl,Jsp Tags,我第一次做JSTL编码,在使用if-else条件(c:when和c:choose)时遇到了一些问题 我需要的if-else嵌套的psuedo代码是 if(${not empty properties['userrgba']}){ <div style = "background-color: ${properties['userrgba']};"> } else if({not empty properties['userColor']}) {

我第一次做JSTL编码,在使用if-else条件(c:when和c:choose)时遇到了一些问题

我需要的if-else嵌套的psuedo代码是

if(${not empty properties['userrgba']}){
    <div style = "background-color: ${properties['userrgba']};">
}


    else if({not empty properties['userColor']})
    {
        if({not empty properties['userColorGradient']}){
        <div style = "background-color: ${properties['userColor']};
                      background: -webkit-gradient(linear, left top, left bottom, color-stop(50%, ${properties['userColorGradient']}));" >
        }
        else{
        <div style = "background-color: ${properties['userColor']};">
        }
} //END ELSE IF

else{
<div class = ${properties['color']}>
} //END ELSE
第43行是我最后一次做的地方。我考虑了很多,做了很多修改,但每次出现类似的错误都是某一行或另一行(与关闭choose标记或when标记有关)

有什么办法可以修吗


谢谢

更好地缩进您的代码,这样就可以清楚地知道这些事情的开始和结束。没有适当的缩进就不可能找到问题

下面是您的原始代码

<c:choose>
    <c:when test="${not empty properties['userrgba']}">
        <div style = "background-color: ${properties['userrgba']};">
    </c:when>
    <c:otherwise>
        <c:choose>
            <c:when test="${not empty properties['userColor']}">
                <c:choose>
                    <c:when test="${not empty properties['userColorGradient']}">
                        <div style = "background-color: ${properties['userColor']};
                        background: -webkit-gradient(linear, left top, left bottom, color-stop(50%, ${properties['userColorGradient']}));">
                    </c:when>
                    <c:otherwise>
                        <div style = "background-color: ${properties['userColor']};">
                    </c:otherwise>
                </c:choose>
            </c:when>
        </c:choose>
    <c:otherwise> //<-- this should be </c:otherwise>
    <c:otherwise>
        <div class = ${properties['color']}>
    </c:otherwise>
</c:choose>


// 更好地缩进您的代码,以便清楚这些事情的开始和结束。没有适当的缩进就不可能找到问题

下面是您的原始代码

<c:choose>
    <c:when test="${not empty properties['userrgba']}">
        <div style = "background-color: ${properties['userrgba']};">
    </c:when>
    <c:otherwise>
        <c:choose>
            <c:when test="${not empty properties['userColor']}">
                <c:choose>
                    <c:when test="${not empty properties['userColorGradient']}">
                        <div style = "background-color: ${properties['userColor']};
                        background: -webkit-gradient(linear, left top, left bottom, color-stop(50%, ${properties['userColorGradient']}));">
                    </c:when>
                    <c:otherwise>
                        <div style = "background-color: ${properties['userColor']};">
                    </c:otherwise>
                </c:choose>
            </c:when>
        </c:choose>
    <c:otherwise> //<-- this should be </c:otherwise>
    <c:otherwise>
        <div class = ${properties['color']}>
    </c:otherwise>
</c:choose>


//谢谢你建议缩进编辑,我更新了我原来的帖子。我不确定我错在哪里。这是我第一次做jstl。“//@user3861559,
c:choose
是一个类似的
案例
(即开关案例)在C/C++/Java中,和
C:others
类似于
default
:每个开关盒只能有一个
default
。@user3861559,问题是您的伪代码甚至是错误的。一个if statmenet不能有两个
else
块。而不是
else
本身(与
else if
相反)。你上一次的
else
是错误的:删除它。嗨!我的错。我本来想在那里有一个if-else标记。我成功了。谢谢你的帮助。谢谢你建议缩进编辑,我更新了我的原始帖子。我不确定我哪里出错了。这是我第一次使用jstl。“/@user3861559,
c:choose
在c/c++/Java中类似于
case
(即开关case),而
c:other
类似于
default
:每个开关case只能有一个
default
。@user3861559,问题是您的伪代码甚至是错误的。一个if statmenet不能有两个
else
块。本身不
else
(与
else相反,如果
)。您最后的
else
错误:删除它。嗨!我的错。我本来想在那里贴个if-else标签的。我让它工作了。谢谢你的帮助。
<c:choose>
    <c:when test="${not empty properties['userrgba']}">
        <div style = "background-color: ${properties['userrgba']};">
    </c:when>
    <c:otherwise>
        <c:choose>
            <c:when test="${not empty properties['userColor']}">
                <c:choose>
                    <c:when test="${not empty properties['userColorGradient']}">
                        <div style = "background-color: ${properties['userColor']};
                        background: -webkit-gradient(linear, left top, left bottom, color-stop(50%, ${properties['userColorGradient']}));">
                    </c:when>
                    <c:otherwise>
                        <div style = "background-color: ${properties['userColor']};">
                    </c:otherwise>
                </c:choose>
            </c:when>
        </c:choose>
    <c:otherwise> //<-- this should be </c:otherwise>
    <c:otherwise>
        <div class = ${properties['color']}>
    </c:otherwise>
</c:choose>