开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜