开发者

How to pass an arraylist as a request parameter so that i can fetch the values through request parameter

开发者 https://www.devze.com 2023-02-15 07:41 出处:网络
I h开发者_如何学Pythonave a method in a java class that returns an ArrayList of a particular class type. How can it be passed as a request parameter?in your servlet

I h开发者_如何学Pythonave a method in a java class that returns an ArrayList of a particular class type. How can it be passed as a request parameter?


in your servlet

request.setParameter("dataList",methodThatReturnsList());//and forward this request to jsp

on jsp

<c:forEach var="data" item="dataList">
    ${data}
</c:forEach>


Correcting Jigar Joshi:

request.setAttribute("dataList",methodThatReturnsList());//and forward this request to jsp

But this is not a parameter. The request parameters can only be strings (or string arrays), and are generated when you submit a form or you attach the parameters in the query string of an url.

0

精彩评论

暂无评论...
验证码 换一张
取 消