作用:從request 裏獲取指定屬性的值。
傳入參數: 有兩類方法
- 無默認值 —— get[DateType]( ServletRequest req, String param ): 其中紅色[DateType] 表示所預知返回屬性值的類型。比如當所獲取屬性爲時間(Date)類型時可調用getDate(ServletRequest req, String param, DateFormat df),其中Param 爲字符串型的屬性名。該方法獲得的即爲ServletRequest 類的實例req 中,名爲param 的屬性的時間值,並以 df 的形式表示。
- 有默認值 :有默認值時可有兩種方法調用。
- get[DateType]( ServletRequest req, String param, [DateType] defaultValue ): 其中紅色[DateType] 表示所預知返回屬性值的類型。比如當所獲取屬性爲時間(Date)類型時可調用getDate(ServletRequest req, String param, DateFormat df, Date defaultValue),其中Param 爲字符串型的屬性名。該方法獲得的即爲ServletRequest 類的實例req 中,名爲param 的屬性的時間值,並以 df 的形式表示。若未能從req 中獲取到值,則返回默認值defaultValue。
- get(ServletRequest req, String param, [DateType] defaultValue): 其中紅色[DateType] 表示所預知返回屬性值的類型。比如當所獲取屬性爲時間(Date)類型時可調用get (ServletRequest req, String param, DateFormat df, Date defaultValue),其中Param 爲字符串型的屬性名。該方法獲得的即爲ServletRequest 類的實例req 中,名爲param 的屬性的時間值,並以 df 的形式表示。若未能從req 中獲取到值,則返回默認值defaultValue。