2015-11-09 23 views
0

變量字符串和上下文參數值之間的比較失敗如果s_dlText以字符串"Shipping costs"開頭,則執行c:when指令中的代碼(字"Pass1"出現在結果頁中):使用fn:startsWith

<c:choose> 
    <c:when test="${fn:startsWith(s_dlText, 'Shipping costs') == true}"> 
    <br /> 
    Pass1 
    <br /> 
    </c:when> 
</c:choose> 

而在下列情況下,再次,如果s_dlText開始用字符串"Shipping costs",不執行c:when指令裏面的代碼(字"Pass2"沒有出現在結果頁面):

<c:choose> 
    <c:when test="${fn:startsWith(s_dlText, S_SHIPPING_COSTS) == true}"> 
    <br /> 
    Pass2 
    <br /> 
    </c:when> 
</c:choose> 

S_SHIPPING_COSTS被宣佈爲web.xml如下:

<context-param> 
    <param-name>S_IF_MSG_SHIPPING_COSTS</param-name> 
    <param-value><![CDATA[Shipping costs]]></param-value> 
</context-param> 

你看到什麼不正在做正確的方式?謝謝。

注1

需要注意的是,如果我刪除了<![CDATA[]]>標記,該行爲是相同的。

回答

1

用途:<c:when test="${fn:startsWith(s_dlText, initParam.S_SHIPPING_COSTS)}">,你並不需要在你的web.xml

+0

很不錯<![CDATA[]]>標記。謝謝。有用。 –