今天下手的時候突然間有個疑問,為什么struts2 的標簽庫的路徑(uri)是:/struts-tags? 在那設置的?能設置成別的嗎?在網上找了一下,(又是在要放棄的時候堅持了一小下!嘿嘿……以后要減少解決問題的時間~)
struts2 的web 項目中為了方便的編寫jsp,在jsp中引入了標簽庫<&@ taglib uri="/struts=tags" prefix="s">
struts2 標簽庫的定義在**-core-版本號.jar META-INF 路徑下找到struts-tags.tld文件;使用該標簽需要在web 項目里面導入標簽庫:
A:在web.xml文件 (默認 可以省略)
<taglib>
<taglib-uri>/struts-tags</taglib-uri>
<taglib-location>/WEB-INF/lib/*.jar</taglib-location>
<taglib>
B:在jsp 導入標簽的定義
<%@ taglib prefix="s" uri="/struts-tags"%>
注意uri要一致,上面定義的是默認寫法
也就是說,在web.xml中已經默認配置了struts2 的標簽庫的rui,默認是/struts-tags,可以自己重新設置標簽庫的路勁uri的值:
<jsp-config>
<taglib>
<taglib-uri>struts2</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-tags.tld</taglib-location>
</taglib>
</jsp-config>
重新設置的條件是你有struts-tags.tld的路徑~嘿嘿……所以野豬感覺還是使用默認的吧……知道為什么就行了~