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