首先request中的參數parameter是一個map表,如下例
map={username=[xxx],password=[xxx],hobby=[eat,drink]}
(1)當調用getParameter(“hobby”)時只能獲取hobby[0] ,即eat。
(2)調用getParameterValues(“hobby”)時能獲取hobby=[eat,drink]這個數組。
(3)調用getParameterMap時能獲取整個map對象。
爲了驗證,我就隨便在自己的jsp登陸頁面上傳的url中手動添加了hobby參數
然後在程序中獲取:
jsp頁面action附加代碼如下:
在Servlet中獲取並打印如下:
部分轉載自:
http://blog.csdn.net/qq_23121031/article/details/77334430