bou*_*ppo 5 html javascript jsp struts
当用于创建myBean的值不为null时,以下代码片段起作用.
当myBean值为null 时,如何处理场景?有没有办法检查bean的价值?
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
Run Code Online (Sandbox Code Playgroud)
现在if myName和/或myProp为null,
错误 javax.servlet.jsp.JspException: Define tag cannot set a null value错误.
尝试解决方案:
<c:if test="${not empty myBean}">
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
</c:if>
Run Code Online (Sandbox Code Playgroud)
@bouncingHippo 使用 struts 逻辑标记来进行空检查。喜欢,
<logic:present name="<%=myName%>" property="<%=myProp%>">
<bean:define id="myBean" name="<%=myName%>" property="<%=myProp%>"/>
</logic:present>
Run Code Online (Sandbox Code Playgroud)
让我知道这是否有帮助..