我是靠谱客的博主 简单乌龟,最近开发中收集的这篇文章主要介绍Struts2 控制 标签 之 if elseif else,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

创建 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 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所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(70)

评论列表共有 0 条评论

立即
投稿
返回
顶部