浏览 4153 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-04-06
<ww:if test="#session.id == 10" > ... </ww:if> 给每个比较的表达式上加上“'”也不好用。这是为什么啊? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2005-04-06
<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="webwork" prefix="ww" %> <% //just for test request.getSession();.setAttribute("id","10");; request.getSession();.setAttribute("id2",new Integer(10););; %> <html> <head> <title>My JSP 'start.jsp' starting page</title> </head> <body> <ww:if test="#session.id == '10'" > string </ww:if> <br> <ww:if test="#session.id2 == 10" > integer </ww:if> </body> </html> |
|
返回顶楼 | |
发表时间:2005-04-07
呵呵,你这样做没有问题,可是我这里有问题啊。
页面1 -> action -> 结果页面 页面1 <a href="nav.action?no=4" >Go </a> nav.action类代码 public class Navigate extends ActionSupport{ private String no = ""; //getter/setter public String execute()throws Exception{ if(this.no != null && !"".equals(this.no)){ ActionContext.getContext().getSession().put("id",no); } return SUCCESS; } } 结果页面 <ww:property value="#session.id" /> <ww:if test="#session.id == '4'" > Result is 4 </ww:if> <ww:if test="#session.id == '2'" > Result is 2 </ww:if> 在结果页面中 <ww:property value="#session.id" /> 能够正确的输出session中的id值。可是这个判断即使条件为真,也无法输出结果。 |
|
返回顶楼 | |
发表时间:2005-04-07
哦.......以前好像有个文章,被删除了
看这里吧 http://www.jscud.com/news/viewnews.jspa?nid=26 or http://wiki.opensymphony.com/display/WW/FAQ Why won't the 'if' tag evaluate a one char string? |
|
返回顶楼 | |
发表时间:2005-04-07
谢谢scud,呵呵,问题解决了.
|
|
返回顶楼 | |