search

Home  >  Q&A  >  body text

java - EL表达式嵌套问题,嵌套报错,希望大神帮忙看看,贴上代码

          <p class="col-xs-2">
                <select id="chapterType" name="chapterType" class="form-control" >
                    <c:forEach items="${chapterType}" var="cType" >
                        <option value="${cType.id}"
                                <c:if test="${chapter.chapterType==${cType.id}}">selected = selected</c:if>>
                            ${cType.name}
                        </option>
                    </c:forEach>
                </select>
            </p>
巴扎黑巴扎黑2803 days ago482

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-18 10:54:24

    First of all, el expressions should not be nested inside el expressions, such as ${chapter.chapterType==${cType.id}},至少应该写成${chapter.chapterType==cType.id}.

    Secondly, I don’t know much about the principles of jsp compilation. For example, will there be any problem if the tag is embedded in the xml tag? If you have to make a judgment in the tag, you might as well use el expression instead<c:if>,比如:${chapter.chapterType==cType.id ? " selected=selected" : ""}

    reply
    0
  • Cancelreply