![](/img/trans.png)
[英]How to set variable in jsp using jstl from input tag on same page?
[英]How to check a request parameter in JSP using JSTL, especially <c:set> tag?
我正在嘗試使用標簽解析JSP中的請求參數:和
參數是namer結果,所以我在jsp中的變量是requestScope [“result”]
我確實有兩個問題:1)我想檢查兩種情況:param是否為空,我使用下面的代碼
<c:if test='${not empty requestScope["result"]}'>
<c:set var = "result" value = '${requestScope["result"] }'/>
</c:if>
<c:if test='${empty requestScope["result"]}'>
<c:set var = "result" value = ' not available'/>
</c:if>
為了在結果變量中設置結果請求,或者如果它為null則設置“不可用”值
此代碼始終顯示不可用,但是當我刪除第二個測試時,它會顯示結果
我也嘗試了'${param.result != null}'
測試,它給出了相同的結果。
先感謝您
我有類似的代碼,這種方式適合我:
<c:set var="result" value="${(requestScope['result'] == null || requestScope['result'] eq '') ? 'not available' : ${requestScope['result']}}"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.