當(dāng)前位置:軟件學(xué)堂 > 資訊首頁 > 網(wǎng)絡(luò)編程 > 編程其他 > Struts2 標(biāo)簽

Struts2 標(biāo)簽

2012/12/1 11:07:00作者:佚名來源:網(wǎng)絡(luò)

移動端

對于代碼方面的知識,小編在前面也給大家有過這方面的介紹,今天接著來給大家講解Struts2標(biāo)簽是什么意思。小編在這里給大家總結(jié)了兩個方面,希望對大家有所幫助。

struts2標(biāo)簽總體來說分為兩大類:UI標(biāo)志和非UI標(biāo)志,下面看看struts2標(biāo)簽的具體內(nèi)容:

1、UI標(biāo)志

其中在UI標(biāo)簽中又可以分為表單UI和非表單UI,表單UI基本上和Struts1.x標(biāo)簽相同,都是對HTML的表單元素進(jìn)行包裝。但是對于Struts2來說,我們經(jīng)常會在一些項目中用到:datepicker、doubleselect、timepicker、 optiontransferselect等。下面我們一起來看看具體UI的用法,相信大家就會明白了。

form: 
<s:form action="exampleSubmit" method="post" enctype="multipart/form-data"> 
<s:submit   /> 
<s:reset   /> 
</s:form>可以上傳文件的form。 
textfield: 
<s:textfield 
             label="姓名:" 
             name="name" 
             tooltip="Enter your Name here" /> 
datepicker: 
<s:datepicker 
             tooltip="Select Your Birthday" 
             label="生日" 
             name="birthday" /> 
textarea: 
<s:textarea 
             tooltip="Enter your remart" 
             label="備注" 
             name="remart" 
             cols="20" 
             rows="3"/> 
select: 
<s:select 
             tooltip="Choose user_type" 
             label="" 
             list="#{'free':'免費(fèi)','vip':'收費(fèi)'}" value="#{'free':'免費(fèi)'}"   
           name="bean.user_type" 
             emptyOption="true" 
             headerKey="None" 
             headerValue="None"/> 
<s:select 
             tooltip="Choose user_type" 
             label="" 
             list="#{'free':'免費(fèi)','vip':'收費(fèi)'}" value="#{'free':'免費(fèi)'}"   
           name="bean.user_type" 
             emptyOption="true" 
             headerKey="None" 
             headerValue="None"/> 
<s:select 
list="venderList" 
listKey="id" 
listValue="name" 
value="%{profile.companyName}" 
name="companyName" cssClass="sel_style_w_180"/>   
挺好用的 
checkboxlist: 
<s:checkboxlist 
             tooltip="Choose your Friends" 
             label="朋友" 
             list="{'Patrick', 'Jason', 'Jay', 'Toby', 'Rene'}" 
             name="friends"/> 
checkbox: 
   <s:checkbox 
             tooltip="Confirmed that your are Over 18" 
             label="年齡" 
             name="legalAge" 
            value="18"/> 
file: 
   <s:file 
             tooltip="Upload Your Picture" 
             label="Picture" 
             name="picture" /> 
a: 
<s:a href="getP.jsp">超鏈接提交</s:a> 
date : 
<s:date name="ad_end_time" format="yyyy-MM-dd"/> 

2、非UI標(biāo)志

非UI標(biāo)志對if、elseif和else的描述:執(zhí)行基本的條件流轉(zhuǎn)。

<%@ page c %> 
<%@ taglib prefix="s" uri="/struts-tags" %> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<title>Condition Flow</title> 
</head> 
<body> 
<h3>Condition Flow</h3>             
<s:iterator value="linkList" status="bean"> 
<tr> 
<td class="data_tab_tdcl"> 
<s:property value="#bean.Index+1" /></td> 
<td class="data_tab_tdcl"><s:property value="link_title" /></td> 
<td class="data_tab_tdcl"><s:property value="link_url" /></td> 
<td class="data_tab_tdcl"> 
<s:if test="link_type == 1"> 
文字 
</s:if> 
<s:elseif test="link_type == 2"> 
圖片 
</s:elseif> 
<s:else> 
----- 
</s:else>    
</td> 
</body>
</html> 

以上就是關(guān)于Struts2 標(biāo)簽的全部內(nèi)容,希望對大家有所幫助,更多詳細(xì)資料請繼續(xù)瀏覽學(xué)無憂。

標(biāo)簽: Struts2  標(biāo)簽