首先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中獲取並打印如下:
https://blog.csdn.net/Jungle_hello/article/details/77620394