论坛首页 Java企业应用论坛

请问ww标签<ww:if test>的一个问题

浏览 11734 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2005-08-24  
robin的办法是绝对可行的。
0 请登录后投票
   发表时间:2005-09-21  
webwork自带文档的faq中就有对这个的详细解答:
How can I put a String literal in a Javascript call, for instance in an onChange attribute?

The problem is in escaping quotes and getting the double quotes around the final value, like we expect in HTML attributes. Here's an example of the right way to do this (thanks to John Brad):

onchange='"someFunc(this.form, \'abc\')"'
Notice here that there are single quotes surrounding the double quotes, and then the single quotes inline in the Javascript are escaped. This produces this result:

onchange="someFunc(this.form, 'abc')"
Why won't the 'if' tag evaluate a one char string?

<ww:if test="#myObj.myString == 'A'">
Why doesn't this work when myString is equal to A?
</ww:if>

OGNL will interpret 'A' as a char type and not a string. Simple solution - flip the double and single quotes.
<ww:if test='#myObj.myString == "A"'>
This works!
</ww:if>
Alternatively, you can escape the double quotes in the String:

<ww:if test="#myObj.myString == \"A\"">
This works!
</ww:if>
0 请登录后投票
   发表时间:2005-09-28  
user.userName eq 'a'
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics