A:
<s:a href=""></s:a>-----超鏈接,類似于html里的<a></a>
<s:action name=""></s:action>-----執行一個view里面的一個action
<s:actionerror/>-----如果action的errors有值那么顯示出來
<s:actionmessage/>-----如果action的message有值那么顯示出來
<s:append var="newMerList">-----添加一個值到list,類似于list.add();
<s:param value="merList1"></s:param>
<s:param value="merList2"></s:param>
</s:append>
<s:autocompleter></s:autocompleter>-----自動完成<s:combobox>標簽的內容,這個是ajax
B:
<s:bean name=""></s:bean>-----類似于struts1.x中的,JavaBean的值
C:
<s:checkbox></s:checkbox>-----復選框
<s:checkboxlist list=""></s:checkboxlist>-----多選框
<s:combobox list=""></s:combobox>-----下拉框
<s:component></s:component>-----圖像符號
D:
<s:date name="time" format="yyyy/MM/dd"/>-----獲取日期格式
<s:datetimepicker></s:datetimepicker>-----日期輸入框
<s:debug></s:debug>-----顯示錯誤信息
<s:div></s:div>-----表示一個塊,類似于html的<div></div>
<s:doubleselect list="#appVar3" listKey="id" listValue="name" name="" doubleName="chinagra.chinagraCategory.id" -----雙下拉框
doubleId="mid" doubleList="#appVar4.get(top.id)" doubleListKey="id" doubleListValue="title" theme="simple"/>
List<Category> categories = chinagraService.searchProblemCategories();;
Map<Long, List<ChinagraCategory>> chinagraCategories = new HashMap<Long, List<ChinagraCategory>>();
for(Category category : categories) {
chinagraCategories.put(category.getId(), chinagraCategoryService.queryByType(category.getId().toString()));
}
E:
<s:if test=""></s:if>
<s:elseif test=""></s:elseif>
<s:else></s:else>-----這3個標簽一起使用,表示條件判斷
F:
<s:fielderror></s:fielderror>-----顯示文件錯誤信息
<s:file></s:file>-----文件上傳
<s:form action=""></s:form>-----獲取相應form的值
G:
<s:generator separator="'aaa,bbb,ccc,ddd'" val=",">
<s:iterator>
<s:property/>
</s:iterator>
</s:generator>----和<s:iterator>標簽一起使用
H:
<s:head/>-----在<head></head>里使用,表示頭文件結束
<s:hidden name="user.name" value="junly"/></s:hidden>-----隱藏值
I:
<s:i18n name=""></s:i18n>-----加載資源包到值堆棧
<s:include value=""></s:include>-----包含一個輸出,servlet或jsp頁面
<s:inputtransferselect list=""></s:inputtransferselect>-----獲取form的一個輸入
<s:iterator value="userlist" var="user" status="s">
<s:if test="#s.index == 0">
<s:property value="name"/>
</s:if>
<s:property value="#s.even"/>
<s:property value="#s.odd"/>
<s:property value="#s.first"/>
<s:property value="#s.last"/>
<s:property value="#s.count"/>
</s:iterator>-----用于遍歷集合
<s:if test="#list.size > 0 "></s:if>-----判斷 ActionContext.getContext().put("list", lists);
<s:elseif test="list.size > 0 "></s:elseif>
<s:else></s:else>
<s:if test="searchCondition.filter!=null">
L:
<s:label></s:label>-----只讀的標簽
M:
<s:merge></s:merge>-----合并遍歷集合出來的值
O:
<s:optgroup></s:optgroup>-----獲取標簽組
<s:optiontransferselect doubleList="" list="" doubleName=""></s:optiontransferselect>-----左右選擇框
P:
<s:param name="pageSize" value="pageSize"/></s:param>-----為其他標簽提供參數
<s:password></s:password>-----密碼輸入框
<s:property value="user.name" />-----得到'value'的屬性
<s:push value=""></s:push>-----value的值push到棧中,從而使property標簽的能夠獲取value的屬性
R:
<s:radio name="type" list="#{0:'拍賣會',1:'展會'}" value="0"></s:radio>-----單選按鈕
<s:reset></s:reset>-----重置按鈕
S:
<s:select list=""></s:select>-----單選框
<s:set name=""></s:set>-----賦予變量一個特定范圍內的值
<s:sort comparator=""></s:sort>-----通過屬性給list分類
<s:submit></s:submit>-----提交按鈕
<s:subset source="#subList" start="1" count="2">-----為遍歷集合輸出子集
<s:iterator>
<s:property/>
</s:iterator>
</s:subset>
T:
<s:tabbedPanel id=""></s:tabbedPanel>-----表格框
<s:table></s:table>-----表格
<s:text name="error"/></s:text>-----I18n文本信息
<s:textarea></s:textarea>-----文本域輸入框
<s:textfield></s:textfield>-----文本輸入框
<s:token></s:token>-----攔截器
<s:tree></s:tree>-----樹
<s:treenode label=""></s:treenode>-----樹的結構
U:
<s:updownselect list=""></s:updownselect>-----多選擇框
<s:url value="/academy/get-detail.action?academyInfo.id=${id}"></s:url>-----創建url
<s:url action="search-big.action" escapeAmp="false" namespace="/problem">
<s:param name="name" value="%{'all'}"/>
<s:param name="id" value="0"/>
<s:param name="sex" value="user.sex"/>
</s:url>
JSTL語法及參數
JSTL包含以下的標簽:
常用的標簽:如<c:out>、<c:remove>、<c:catch>、<c:set>等
條件標簽:如<c:if><c:when>、<c:choose>、<c:otherwise>等
URL標簽:如<c:import>、<c:redirect>和<c:url>等
XML標簽:如<xml:out>等
國際化輸出標簽:如<fmt:timeZone>等
SQL標簽:如<sql:query>、<sql:update>、<sql:transaction>等
一般用途的標簽:
1.<c:out>
沒有Body時的語法
<c:out value=”value” [escapeXml=”{true|false}”] [default=”defaultValue”]/>
有Body時的語法
<c:out value=”value” [escapeXml=”{true|false}”]>
這里是Body部分
</c:out>
名字 類型 描述
value Object 將要輸出的表達式
escapeXml boolean 確定以下字符:<,>,&,’,”在字符串中是否被除數,默認為true
default Object 如果vaule計算后的結果是null,那么輸出這個默認值
2.<c:set>
這個標簽用于在某個范圍(page、request、session、application等)中使用某個名字設定特定的值,或者設定某個已經存在的javabean對象的屬性。他類似于<%request.setAttrbute(“name”,”value”);%>
語法1:使用value屬性設定一個特定范圍中的屬性。
<c:set value=”value” var=”varName” [scope=”{page|request|session|application}”]/>
語法2:使用value屬性設定一個特定范圍中的屬性,并帶有一個Body。
<c:set var=”varName” [scope=”{page|request|session|application}”]>
Body部分
</c:set>
語法3:設置某個特定對象的一個屬性。
<c:set value=”value” target=”target” property=”propertyName”/>
語法4:設置某個特定對象的一個屬性,并帶有一個Body。
<c:set target=”target” property=”propertyName”>
Body部分
</c:set>
名字 類型 描述
value Object 將要計算的表到式。
var String 用于表示value 值的屬性,如果要在其他標簽中使用,就是通過這 個var指定的值來進行的。它相當于在標簽定義了一個變量,并且這個變量只能在標簽中的一個。
scope String var的有效范圍,可以是page|request|session|application中的一個
target String 將要設置屬性的對象,它必須是javabean或則java.util.Map對象
property Object 待設定的Target對象中的屬性名字,比如在javabean中有個name屬性,提供了setUserId方法,那么這里填userId。
3.<c:remove>
<c:remove var=”varName” [scope=”{page|request|session|application}”]/>
4.<c:catch>
這個標簽相當于捕獲在它里邊的標簽拋出的異常對象
<c:catch [var=”varName”]> //var是異常的名字
內容
</c:catch>
條件標簽
1. <c:if>
語法1:無Body情況
<c:if test=”testCondition” var=”varName” [scope=”page|request|session|application”]/>
語法2:有Body的情況
<c:if test=”testCondition” var=”varName” [scope=”page|request|session|application”]>
Body內容
</c:if>
名字 類型 描述
test Boolean 表達式的條件,相當于if()中的條件判斷語句。
var String 表示這個語句的名字。
scope String var這個變量的作用范圍。
2.<c:choose>
語法:<c:choose>
Body內容(<c:when>和<c:otherwise>子標簽)
</c:choose>
注意:它的Body只能由以下元素組成:
1) 空格
2) 0或多個<c:when>子標簽,<c:when>必須在<c:otherwise>標簽之前出現.
3) 0個或多個<c:otherwise>子標簽。
<c:choose>
<c:when test="${param.age>70}">
歡迎老年人
</c:when>
<c:when test="${param.age<70 and param.age>35}">
歡迎中年人
</c:when>
<c:otherwise>
您的年齡有誤!
</c:otherwise>
</c:choose>
3.<c:when>
代表的是<c:choose>的一個條件分支,只能在<c:choose>中使用
語法:<c:when test=”testCondition”> //test是boolean類型,用于判斷條件真假
Body語句
</c:when>
4.<c:otherwise>
代表的是<c:choose>中的最后選擇。必須在最后出現
<c:otherwise>
內容
</c:otherwise>
迭代標簽
1.<c:forEach>
語法1:在Collection中迭代
<c:forEach[var=”varName”] items=”collection” [varStatus=”varStatusName”]
[begin=”begin”] [end=”end”] [step=”step”]
Body內容
</c:foeEach>
語法2:迭代固定的次數.
<c:forEach [var=”varName”] [varStatus=”varStatusName”]
[begin=”begin”] [end=”end”] [step=”step”]
Body內容
</c:foeEach>
名字 類型 描述
var String 迭代的參數,它是標簽參數,在其他標簽中通過它來引用這個標簽中的內容。
Items Collection、ArrayList、 要迭代的items集合.
Iterator、Map、String、
Eunmeration等
VarStatus String 表示迭代的狀態,可以訪問迭代自身的信息
Begin int 表示開始迭代的位置。
End int 表示結束迭代的位置。
Step int 表示迭代移動的步長,默認為1。
URL相關的標簽
1.<c:import>
語法1:資源的內容使用String對象向外暴露
<c:import url=”url” [context=”context”]
[var=”varName”] [scope=”{page|request|session|application}”] [charEncoding=”charEncoding”]>
內容
</c:import>
語法2:資源的內容使用Reader對象向外暴露。
<c:import url=”url” [context=”context”]
varReader=”varReaderName” [charEncoding=”charEncoding”]>
內容
</c:import>
名字 類型 描述
url String 待導入資源的URL,可以是相對路徑和絕對路徑,并且可以導入其他主機資源
context String 當使用相對路徑訪問外部context資源時,context指定了這個資源的名字。
var String 參數的名字。
scope String var參數的作用范圍。
cahrEncoding String 輸入資源的字符編碼。
varReader String 這個參數的類型是Reader,用于讀取資源。
2.<c:redirct>
語法1:沒有Body的情況.
<c:redirect url=”value” [context=”context”]/>
語法2:有Body情況下,在Body中指定查詢的參數
<c:redirect url=”value” [context=”context”]>
<c:param name=”name” value=”value”/>
</c:redirect>
3.<c:url>
語法1:沒有Body
<c:url value=”value” [context=”context”] [var=”varName”] [scope=”{page|request|session+application}”]/>
語法2:有Body
<c:url value=”value” [context=”context”] [var=”varName”] [scope=”{page|request|session+application}”]>
<c:param name=”name” value=”value”/>
</c:url>
名字 類型 描述
value String URL值
context String 當使用相對路徑訪問外部context資源時,context指定了這個資源的名字
var String 標識這個URL標量。
Scope String 變量作用范圍。
SQL相關的標簽
1.<sql:setDataSource>
2.<sql:query>
3.<sql:update>
4.<transaction>
5.<param>