${form.test} 打印“var”,但 ${form.test== 'var'} 始终为 false
当我尝试在 JSP 中打印一个值时,它打印名为 "var" 的值,但是当我尝试在 if 条件中使用相同的值时,它似乎不起作用。请有人帮助我...:(:(
<c:out value="${form.test}" /> /* for printing and it's printing "var"*/
<c:if test="${form.test== 'var'}"> /* for if condition which is not working */
when I tried to print a value in JSP, it's printing the value which is named "var" but when I tried to use the same value in a if condition it doesn't seem to be working. Please somebody help me...:(:(
<c:out value="${form.test}" /> /* for printing and it's printing "var"*/
<c:if test="${form.test== 'var'}"> /* for if condition which is not working */
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它应该可以正常工作,假设这些双引号不是值的一部分(即您看到的是
var
,而不是"var"
)。也许该值周围有一些悬空的空白?您可以通过以下方式调试其中一种或另一种:
它
确实是空格并且您无法在 servlet/SQL 端修剪它,请考虑使用
fn:trim()
:如果 “http://download.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fn/tld-summary.html”rel="nofollow">JSTL 函数 标签库可以通过以下方式获得:以下标记库声明:
It should work fine, assuming that those doublequotes are not part of the value (i.e. you're seeing
var
, not"var"
). Perhaps there's some dangling whitespace around the value?You could debug the one and other the following ways:
and
If it is indeed the whitespace and you cannot trim it in the servlet/SQL end, consider using
fn:trim()
:The JSTL functions taglibrary is by the way available by the following taglib declaration:
尝试:
Try: