我在尝试在JSP中输出数组时遇到问题:
@RequestMapping(value="/searchResult.do", method = RequestMethod.POST)
ModelAndView search(HttpServletRequest request, HttpServletResponse response) throws SQLException
{
String keyword = request.getParameter("keyword");
String within = request.getParameter("witin");
String status = request.getParameter("status");
String query="select id,title,description,story_type,uploaded_date,popularity from story where status='"+status+"' and title like '"+'%'+keyword+'%'+"'";
stmt= (Statement) DBManager.getMyConnection();
rs = stmt.executeQuery(query);
Map map = new HashMap();
List wordList = new ArrayList();
if(keyword!=null){
while (rs.next()) {
String id = rs.getString("id");
String title = rs.getString("title");
String description = rs.getString("description");
String parent = rs.getString("uploaded_date");
String type = rs.getString("story_type");
String pop = rs.getString("popularity");
wordList.add(id);
wordList.add(title);
wordList.add(type);
wordList.add(description);
wordList.add(parent);
wordList.add(pop);
map.put("wordList", wordList);
}
return new ModelAndView("searchResult",map);
}
return new ModelAndView("search");
}
在JSP中我使用${wordList}
打印
[20,印度赢得了世界杯,体育,这个 是我的杯子,2011-03-26,2,27,印度 赢得世界杯,体育,xyz,2011-04-08, 2]
......这些是一个数组中的两个记录。
如何在JSP中的单独行中打印每个项目?