Struts2頁面開發中常用標籤使用規範

2021-07-30 18:37:06 字數 1345 閱讀 1325

1.1.通過form表單

往action中傳值,action中要有相應的屬性,並提供set/get方法。

(在數量少時可以使用request.getparameter(「username」);

1.2.往action中的實體物件內傳值,使用textfield標籤。

1.3.在頁面顯示action傳來的資料,使用property標籤。需要顯示的資料從action中獲得。

property value=" username "/> 當action返回到指定頁面是,可以通過該標籤顯示action中的屬性資訊。(注 username必須在action中存在,並有get方法)。
1.4.在頁面中判斷指定值使用標籤。判斷資料從action中獲得。

if test="username == admin">…. if>

else>…. else>

1.5.在頁面中需要迴圈列表顯示的資料使用標籤,列表資料從action中獲得。

value="userlist"

id="user"

status="u">

value="username"/>

a>

s:iterator>

1.6.url位址和超連結可以使用,在傳多值時建議一起使用 。

href="

">

name=" "

value="">

s:param>

name=" "

value="">

s:param>

name=" "

value="">

s:param>

s:url>">

超連結a>

url位址標籤,用於生成乙個url位址,可以通過url標籤指定的param>子元素向url位址傳送請求引數

" ">

param name=" "

value="">param>

其中action為請求位址,param子元素為位址後面所帶的引數。

附加2.1

set name="user"

value="username" scope=」request」/>

將user值放入request範圍內。

Struts2頁面開發中常用標籤

struts2頁面開發中常用標籤使用說明 1.1 往action裡傳值的使用方式 a.username屬性需要在訪問的action中提供相應的屬性,並有set get方法。b.可以不在訪問的action中提供相應的屬性,用request.getparameter username 1.2 顯示標籤 ...

Struts2頁面開發中常用標籤使用規範

1 struts2頁面開發中常用標籤使用說明 1.1 往action裡傳值的使用方式 a.username屬性需要在訪問的action中提供相應的屬性,並有set get方法。b.可以不在訪問的action中提供相應的屬性,用request.getparameter username 1.2 顯示標...

Struts2頁面開發中常用標籤使用說明

1 struts2頁面開發中常用標籤使用說明 1.1 往action裡傳值的使用方式 a.username屬性需要在訪問的action中提供相應的屬性,並有set get方法。b.可以不在訪問的action中提供相應的屬性,用request.getparameter username 1.2 顯示標...