从后台获取一个类,类的定义如下:public class JzBusiness implements java.io.Serializable {
private static final long serialVersionUID = 6568165014358134335L;
private Integer bsId;
private String bsname;
private String comments;
private Integer remindtype;
private Set jzGtypes = new HashSet(0);这里面有个jzGtypes的集合存有jzGtype类。在javascript需要判断jzGtype是否为空,如下:<logic:iterate id="business" scope="request" name="allbusiness" indexId="ind">
             if(jzGtypes不为空){
<logic:iterate id="gtype" name="business" property="jzGtypes">
business_id[<%=temp%>]=new Array("${business.bsId}");
gtype_id[<%=temp%>]=new Array("${gtype.gtId}");
gtype_name[<%=temp%>]=new Array("${gtype.gtName}");
remindtype_id[<%=temp%>]=new Array("${business.remindtype}");
<%temp++ ;%>
</logic:iterate>
              }else(jzGtype为空){
    business_id[<%=temp%>]=new Array("${business.bsId}");
    remindtype_id[<%=temp%>]=new Array("${business.remindtype}");        <%temp++ ;%>
         }
</logic:iterate>这个如何在javascript写 if(jzGtypes不为空){,谢谢!

解决方案 »

  1.   

    if(jzGtypes不为空){ 改成  <%if(jzGtypes不为空){ %>不就OK了? 或者用EL表达式
    <c:if test="${jzGtypes!=null}">
      

  2.   

    if(jzGtypes不为空){如果是js, 你确认??if(if(jzGtypes)
    或者
    if(jzGtypes!=null)还有
    if(jzGtypes!=null && jzGtypes!="")
      

  3.   

    您没看明白我的意思,从后台取到对象是business,在这个business对象中有集合jzGtypes,还有其他的东西,因为business和jzGtypes是一对多的关系,在取jzGtypes集合中的东西的时候我需要判断一下jzGtypes是否为空所以不能是<c:if test="${jzGtypes!=null}">,因为得到的是business,不是jzGtypes.
      

  4.   

    js里除了null还有undefined,只判断null可能不够.
    jzGtypes是个类的话,可以严格一点if(typeof jzGtypes!='object')
      

  5.   


    你不是用的是struts logic标签吗?
    那继续用logic标签啊...
    logic:empty
    logic:notEmpty...
      

  6.   

    那用
    logic:empty 
    logic:notEmpty... 
    来判断不就可以了...
      

  7.   

    if(jzGtypes!=null && jzGtypes!="") 
    或者
    logic:empty 
    logic:notEmpty
      

  8.   

    和2楼的一样,用 struts 的 logic 标签就可以了