action標籤,顧名思義,是用來呼叫action的標籤,在jsp中頁面中,可以具體指定某一命名空間中的某一action。而標籤的主體用於顯示及渲染actionr的處理結果。
action標籤有如下幾個屬性:
id: 可選屬性,作為該action的引用id
name:必選屬性,指定呼叫action
namespace:可選屬性,指定該標籤呼叫action所屬namespace
executeresult:可選屬性,指定是否將action的處理結果包含到本頁面中.預設值為false,不包含.
ignorecontextparam:可選引數,指定該頁面的請求引數是否需要傳入呼叫的action中,預設值是false,即傳入引數.
傳遞引數
是以request方式的值的,而不是以引數傳值
所以request.getparameter("")會獲取不到值
通過request.getattribute("")方式可以獲取
另外:使用 value指代的是action定義的物件的名稱,而不是乙個值
和 中的name是乙個意思,所以要要傳遞字串的不能把值寫value中而應該寫到
寫到這裡
public string info() throws exception catch (exception e)
強制將物件轉為int
如果要獲得action傳過來的值,這樣
傳字串的時候要這樣傳
duhuimingpin
隨便講下getparameter和getattribute的區別
httpservletrequest類既有getattribute()方法,也由getparameter()方法,這兩個方法有以下區別:
(1)httpservletrequest類有setattribute()方法,而沒有setparameter()方法
(2)當兩個web元件之間為鏈結關係時,被鏈結的元件通過getparameter()方法來獲得請求引數,例如假定welcome.jsp和authenticate.jsp之間為鏈結關係,welcome.jsp中有以下**:
authenticate.jsp
或者:
在authenticate.jsp中通過request.getparameter("username")方法來獲得請求引數username:
<% string username=request.getparameter("username"); %>
(3)當兩個web元件之間為**關係時,**目標元件通過getattribute()方法來和**源元件共享request範圍內的資料。假定 authenticate.jsp和hello.jsp之間為**關係。authenticate.jsp希望向hello.jsp傳遞當前的使用者名字, 如何傳遞這一資料呢?先在authenticate.jsp中呼叫setattribute()方法:
<%
string username=request.getparameter("username");
request.setattribute("username",username);
%>
在hello.jsp中通過getattribute()方法獲得使用者名字:
<% string username=(string)request.getattribute("username"); %>
hello: <%=username %>
從更深的層次考慮,request.getparameter()方法傳遞的資料,會從web客戶端傳到web伺服器端,代表http請求資料。request.getparameter()方法返回string型別的資料。
request.setattribute()和getattribute()方法傳遞的資料只會存在於web容器內部,在具有**關係的web元件之間共享。這兩個方法能夠設定object型別的共享資料。
request.getparameter()取得是通過容器的實現來取得通過類似post,get等方式傳入的資料,, request.setattribute()和getattribute()只是在web容器內部流轉,僅僅是請求處理階段,這個的確是正解.
getattribute是返回物件,getparameter返回字串
request.getattribute()方法返回request範圍內存在的物件,而request.getparameter()方法是獲取http提交過來的資料。
指定方法
目前都是乙個action配置乙個方法 更好的方法還沒想到
IImage的一些用法
因為美工做出來的圖是png24,帶alpha通道透明的,用傳統的bitblt方法沒有辦法顯示 可能是本人比較笨啦,哈哈 所以採用了iimage的方法來進行畫圖。使用iimage的draw的方法時,要畫區域性是發現總是不對,查了一下msdn,發現是如下的問題。optional const rect s...
gcc 的一些用法
gcc編譯多個原始檔 一.常用編譯命令選項 假設源程式檔名為test.c。3.選項 e 用法 gcc e test.c o test.i 作用 將test.c預處理輸出test.i檔案。4.選項 s 用法 gcc s test.i 作用 將預處理輸出檔案test.i彙編成test.s檔案。5.選項 ...
cursor的一些用法
使用過 sqlite 資料庫的童鞋對 cursor 應該不陌生,如果你是搞.net 開發你大可以把cursor理解成 ado.net 中的資料集合相當於datareader。今天特地將它單獨拿出來談,加深自己和大家對android 中使用 cursor 的理解。關於 cursor 在你理解和使用 a...