我可以在JSP中的URL中传递List作为参数吗?

Nih*_*rma 1 java jsp servlets

我必须将一个List从.jsp传递到我的servlet中,我想通过一个URL来完成它.我能做点什么吗 -

<a href="SellSelectedStockServlet?value=content" target="_self">
Run Code Online (Sandbox Code Playgroud)

其中'content'是List.我想在我的servlet中获取此列表的元素.

或者我只能通过"&"的分隔传递单个参数?

JB *_*zet 13

每个元素的元素都需要一个参数.所有这些参数都应该具有相同的名称:

SellSelectedStockServlet?values=elem1&values=elem2&values=elem3
Run Code Online (Sandbox Code Playgroud)

在servlet中,您将获得所有列表元素,如下所示:

String[] values = request.getParameterValues("values");
// contains elem1, elem2 and elem3.
Run Code Online (Sandbox Code Playgroud)

注意:查询字符串的长度是有限的.不要以这种方式传递大量值.