概述
创建 JSP 页面 IfControlTag.jsp
Set a property 'technologyName' with a value 'Java' as
<s:set name="technologyName" value="%{'Java'}"/>
IfControlTag.jsp
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts 2 Control Tag Example</title>
</head>
<body>
<s:set name="technologyName" value="%{'Java'}"/>
<s:if test="%{#technologyName=='Java'}">
<div><s:property value="%{#technologyName}" /></div>
</s:if>
<s:elseif test="%{#technologyName=='Jav'}">
<div><s:property value="%{#technologyName}" /></div>
</s:elseif>
<s:else>
<div>Technology Value is not Java</div>
</s:else>
</body>
</html>
struts.xml: Add the following xml snippet in the struts.xml file
<action name="doIf" >
<result>/pages/genericTags/IfControlTag.jsp</result>
</action>
In the IfControlTag.jsp only <s:if> tag evaluates to true
<s:if test="%{#technologyName=='Java'}">
<div><s:property value="%{#technologyName}" /></div>
</s:if>
So we get the output equal to Java
最后
以上就是简单乌龟为你收集整理的Struts2 控制 标签 之 if elseif else的全部内容,希望文章能够帮你解决Struts2 控制 标签 之 if elseif else所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复