struts2 1 6 標籤的匯入

2021-08-23 13:55:42 字數 1531 閱讀 5118

剛開始學習struts2,直接就接觸的是最新版本的2.1.6 ,貌似版本與以往的有很多不同之處

所以好多網上的資料都不管用,開始接觸標籤了,卻發現標籤無法匯入

在2.1.6版本中無法找到struts-tags.tld這個檔案,網上找到的好多資料都無效果,

<%@ taglib prefix="s" uri="/struts-tags"%>

都是提示找不到

由於servlet2.4和2.5規範都支援直接匯入標籤,所以無法在web.xml中配置

/struts-tags

/web-inf/struts-tags.tld

網上很多配置為

/struts-tags

/web-inf/lib/struts-core-2.xx.jar

經過測試無效,因為struts-core-.2.1.6.jar檔案中根本沒有struts-tags.tld

標籤算是匯入了接著編寫乙個簡單form表單

編寫乙個struts.properties檔案加入

。。struts.ui.theme=******

struts.ui.templatedir=template

。。

啟動tomcat執行 提示

can't find template/******/form-close.ftl....

我想應該是預設模板配置的問題

在struts-core-2.1.6.jar 沒有找個所謂的template/******

之後在

struts-2.1.6-all\struts-2.1.6\src\core\src\main\resources\template

找到了所以需要的四組ftl模板檔案

於是修改struts.properties配置如下

。。struts.ui.theme=******

struts.ui.templatedir=/web-inf/ftl_lib/ui

。。

之後在/web-inf 下建立

ftl_lib/ui/******

將原始碼包中******目錄下的ftl檔案copy到此目錄下

注意在struts.properties檔案中我們配置為

struts.ui.templatedir=/web-inf/ftl_lib/ui

而在建立目錄的什麼卻要建立為ftl_lib/ui/******

這也是我目前所不能理解的。

因為身邊沒有精通struts2的人都是自己乙個學,問題太多,可能很基礎

Struts2 1 6測試小記

struts2 core 2.1.6.jar freemarker 2.3.13.jar commons logging 1.0.4.jar ognl 2.6.11.jar xwork 2.1.2.jar commons fileupload 1.2.1.jar 要注意的是,struts 2.1.6...

Struts2 1 6測試小記

要注意的是,struts 2.1.6的最小jar包配置比struts2.0.14多了乙個commons fileupload 1.2.1.jar。struts2.0.x所需要的最小jar包請讀者參閱 struts2教程1 第乙個struts2程式 在這篇文章中使用了struts2.0.11.1,該版...

struts2 16 資料檢驗

public class useraction extends actionsupport public void setname string name public string add2 return success 頁面 user add2 error 從struts valuestack ...