admin管理员组文章数量:1356853
The below code snippets work when the values used to create myBean is not null.
How do I take care of the scenario when myBean
has null value? Is there a way to check the bean's value?
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
now if myName
and/or myProp
is null,
Error javax.servlet.jsp.JspException: Define tag cannot set a null value
error.
Attempted solution:
<c:if test="${not empty myBean}">
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
</c:if>
The below code snippets work when the values used to create myBean is not null.
How do I take care of the scenario when myBean
has null value? Is there a way to check the bean's value?
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
now if myName
and/or myProp
is null,
Error javax.servlet.jsp.JspException: Define tag cannot set a null value
error.
Attempted solution:
<c:if test="${not empty myBean}">
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
</c:if>
Share
Improve this question
edited Oct 4, 2013 at 19:59
bouncingHippo
asked Oct 4, 2013 at 19:15
bouncingHippobouncingHippo
6,04023 gold badges71 silver badges110 bronze badges
3
- what doesn't work ? You mean you get a js var myBean value as 'null' string and you want to avoid that ? – Ash Commented Oct 4, 2013 at 19:19
- edited, sorry if i wasn't clear – bouncingHippo Commented Oct 4, 2013 at 19:23
- Hi [this link][1] will bw helpful.This is just a guess [1]: stackoverflow./a/14648106/1069633 – Saurabh Ande Commented Oct 4, 2013 at 19:29
2 Answers
Reset to default 3@bouncingHippo Use struts logic tag for this null checking purpose. Like,
<logic:present name="<%=myName%>" property="<%=myProp%>">
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
</logic:present>
Let me know if this helps..
EDITED as per additional information provided:
<c:if test="${not empty myName}">
... your bean def
</c:if>
Ignore: or maybe something like this: ${empty myBean} or ${not empty myBean} ??
本文标签: htmlchecking if a bean is null using javascript or other methodsStack Overflow
版权声明:本文标题:html - checking if a bean is null using javascript or other methods - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743996581a2573097.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论