JSTL - 比较字符串

时间:2016-08-22 19:57:19

标签: java string jsp jstl equals

我试图比较两个字符串,但我无法得到我需要的结果

我试过这些格式:

<c:choose>
    <c:when test="${company == multi }">
       <a href="dashResumo.jsp?tr=<%=tr%>&company=VVO&nm=<%=nmTorr%>"></a>
       <a href="dashResumo.jsp?tr=<%=tr%>&company=GPA&nm=%=nmTorr%></a>                                    
   </c:when>
 </c:choose>

<c:choose>
    <c:when test="${company == 'multi' }">
       <a href="dashResumo.jsp?tr=<%=tr%>&company=VVO&nm=<%=nmTorr%>"></a>
       <a href="dashResumo.jsp?tr=<%=tr%>&company=GPA&nm=%=nmTorr%>">GPA</a>                                    
   </c:when>
</c:choose>

<c:choose>
    <c:when test="${company.equals("multi") }">
       <a href="dashResumo.jsp?tr=<%=tr%>&company=VVO&nm=<%=nmTorr%></a>
       <a href="dashResumo.jsp?tr=<%=tr%>&company=GPA&nm=%=nmTorr%></a>                                    
   </c:when>
</c:choose>

但这些格式都不适合我。

使用JSTL-1.2库

1 个答案:

答案 0 :(得分:1)

试试这个:

<c:choose>
    <c:when test="${company eq 'multi'}">
        <a href="dashResumo.jsp?tr=<%=tr%>&company=VVO&nm=<%=nmTorr%>">VVO</a>
        <a href="dashResumo.jsp?tr=<%=tr%>&company=GPA&nm=<%=nmTorr%>">GPA</a>                                    
    </c:when>
</c:choose>