如何使用JSTL标记检查Spring mvc 3中的Session变量是否包含null或Not(How to check if a Session variable contain null or Not in spring mvc 3 using JSTL tag )
想要检查会话变量“Sess_Var”是否包含null
<c:if test="${Sess_Var=='NULL'}" > <% response.sendRedirect("doLogin.obj"); %>但它不起作用,它没有检查它
Want to check that session Variable "Sess_Var" contain null or not
<c:if test="${Sess_Var=='NULL'}" > <% response.sendRedirect("doLogin.obj"); %>But its not working,It doesnt check it
最满意答案
如果你的意思是要检查它是否为NULL(而不是检查变量是否包含字符串'NULL',那么你可以这样做
<c:if test="${empty Sess_Var}">这将检查变量是空还是null,如果是,则计算结果为true 。
If you mean you want to check if it is NULL (as opposed to checking if the variable contain the String 'NULL' then you could do
<c:if test="${empty Sess_Var}">This checks to see whether the variable is empty or null and evaluates to true if it is either.
更多推荐
发布评论