在Controller 得到了一个List,并且把这个list放到 map里,传到jsp页面。这个list里的内容是一个复合结构(tfeedback,包括了title content keyword 等)。现在的问题是在jsp页面显示出错
 public String FeedbackListAll(HttpServletRequest request, HttpServletResponse response){

availableItems = tfeedbackService.findAll(Tfeedback.class); 
Iterator<Tfeedback> it = availableItems.iterator();
Map map = new HashMap(); 
        List<Tfeedback> list = new ArrayList<Tfeedback>();
while(it.hasNext())
{
  list.add(it.next());
}
map.put("feedback", list);
     
request.setAttribute("feedbackmap",map);
return "/auth/feedbacklist";
}<table border="0" cellspacing="0" cellpadding="0" width="1000" >
  <tr>
    <td valign="top" align="center" bgcolor="#6da9fb">用户反馈列表</td>
  </tr>
</table>  <c:forEach items="${feedbackmap}" var="feedback" begin ="0" end = "1" varStatus="var">
   ${feedback.title}
  </c:forEach>
还有一个问题是,在Controller里一定要写request.setAttribute("feedbackmap",map); 这句吗?感觉很别扭

解决方案 »

  1.   

    springmvc里有个modelmap的概念
    给事实例@RequestMapping(params="method=login")
    public String login(@Valid User user, BindingResult userResult, @Valid Log log, BindingResult logResult, ModelMap map){
    if(userResult.hasErrors() || logResult.hasErrors()){
    return "error";
    }
    //System.out.println(webRequest.getParameter("username"));
    //System.out.println(request.getParameter("password"));
    System.out.println(log.getBirthday());
    String result = "success";
    map.put("user", user);
    if(!ls.isExist(user)){
    result = "fail";
    }
    return result;
    //return "redirect:http://www.baidu.com";
    }只需要吧是放入modelmap中  前台就能获取值了 另外  springmvc是通过参数传值的  从前台传值的时候只要吧该参数放入 该方法的参数中  springmvc就能自动映射 比如上面方法中的user 和log