在工程中使用struts2標(biāo)簽
一、
struts2標(biāo)簽定義文件在struts2-core-2.0.11.1\META-INF 下面,文件名為
struts-tags
.tld
二、
如果工程使用了servlet2.3規(guī)范,要做兩件事,就能在工程中使用struts2標(biāo)簽了
1: 在web.xml中增加標(biāo)簽庫的定義
<taglib>
???<taglib-uri>/
struts-tags
</taglib-uri>
???<taglib-location>/WEB-INF/lib/struts2-core-2.0.11.1.jar</taglib-location>
??</taglib>
/
struts-tags
是struts2標(biāo)簽庫默認(rèn)的URI,建議使用這個名稱
2 在JSP中使用taglib編譯指令導(dǎo)入標(biāo)簽庫 <%@ taglib prefix="s" uri="/
struts-tags
" %>
三、
如果使用servlet2.4規(guī)范,不須要在web.xml中增加標(biāo)簽庫定義,只要做一件事,就行
1 在JSP中使用taglib編譯指令導(dǎo)入標(biāo)簽庫 <%@ taglib prefix="s" uri="/
struts-tags
" %>
四、
struts2標(biāo)簽自動提示功能(解決struts2標(biāo)簽出現(xiàn)紅叉)
1? 把struts2包中的
struts-tags
.tld提取出來,放入本地硬盤上,我放入了E:\workspace\pic\bin\WEB-INF\tld\
struts-tags
.tld
2 eclipse--window--preferences 輸入TLD進(jìn)行搜索 ,選擇Amateras--TLD開始添加本地TLD文件,
點Add ,URI 項輸入:/
struts-tags
,Local Path項輸入:E:\workspace\pic\bin\WEB-INF\tld\
struts-tags
.tld
點OK? ,重啟eclipse 寫struts2標(biāo)簽時,就有提示了,紅叉也沒了
如圖
?
?
?