[英]How to check a request parameter in JSP using JSTL, especially <c:set> tag?
I'm trying to parse a request param in my JSP using tags: and 我正在尝试使用标签解析JSP中的请求参数:和
The parameter is namer result, so my variable in jsp is requestScope["result"] 参数是namer结果,所以我在jsp中的变量是requestScope [“result”]
I have two problems exactly: 1) I wanna check two cases: param is null or not, I used the following code 我确实有两个问题: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>
In order to set the result from request in result variable or "not available" value if it is null 为了在结果变量中设置结果请求,或者如果它为null则设置“不可用”值
This code always shows not available but when i delete the second test, it shows the result corrctly 此代码始终显示不可用,但是当我删除第二个测试时,它会显示结果
Also I tried with '${param.result != null}'
test, it gives the same result. 我也尝试了'${param.result != null}'
测试,它给出了相同的结果。
Thank you in advance 先感谢您
我有类似的代码,这种方式适合我:
<c:set var="result" value="${(requestScope['result'] == null || requestScope['result'] eq '') ? 'not available' : ${requestScope['result']}}"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.