使用Struts標籤的基本配置

2021-07-09 12:09:29 字數 989 閱讀 8922

使用struts標籤的基本配置

墨爾本晴

5.5.1

使用struts標籤之前需要經過下面3個步驟的配置。

匯入tld檔案。

在web.xml中註冊標籤庫。

在頁面中引入標籤庫。

下面詳細介紹以上步驟。

匯入tld檔案。

tld檔案是struts的標籤庫描述檔案,一般將其直接複製到應用工程的web-inf目錄下,如圖5-6所示。

圖5-6  tld檔案

在web.xml中註冊標籤庫。

01 

02 /web-inf/struts-bean.tld

03 /web-inf/struts-bean.tld

04 05 

06 /web-inf/struts-html.tld

07 /web-inf/struts-html.tld

08 09 

10 /web-inf/struts-logic.tld

11 /web-inf/struts-logic.tld

12 

根據struts版本的不同,在web.xml中註冊標籤庫這一步驟是可以省略的。

在頁面中引入標籤庫。

在jsp頁面中使用標籤引入某個標籤庫,並且給予它乙個對於該頁面有效的字首作為標記,那麼就可以通過其字首使用該標籤庫了。引入標籤庫的**如下:

01 

02 03 

在上面**中,例如將bean標籤庫的字首定義為bean,則可通過字首bean來引用bean標籤庫了,示例如下:

01 

02 

struts 1.3.8的tld檔案內建在struts-taglib-1.3.8.jar中,只需要在jsp頁面中宣告類似如下即可:

或者將struts-taglib-1.3.8.jar解壓縮後將其中的tld檔案複製到web-inf目錄下,再按上述步驟配置。

struts的if標籤使用

下面總結一下struts2 中if標籤的使用 1 判斷字串是否為空 s if test user.username null or user.username s if test ab123 null ab123 is null s if s else ab123 not null s else 2...

struts標籤的使用

最近研究struts時,發現這個標籤能夠解決很多格式上的問題,所以在網上搜尋了一下這個內容,發現這篇文章寫得挺不錯的,挺有收穫。struts 標籤 作用 用來格式化顯示日期的格式。它可以用一種你指定的格式來顯示 如 yyyy mm dd 可以生成通俗易懂的注釋 如 in 2 hours,14 min...

Struts標籤使用

1.1.頁面跳轉 可以使用href page action三個屬性實現struts檢視層元件的跳轉,三個屬性的作用及區別為 href使用該網域名稱下的相對路徑,路徑前不需要加 或鏈結至以http開頭其它網域名稱,href index.jsp href http page使用該網域名稱下的絕對路徑,路...