How to pass a List from the controller to jsp?

Viewed 13848

I am implementing a bulletin board with spring framework.

To show the list of articles on jsp, I got some info from DB and saved it to List<BulletinBoardList>.

What I want to do is to take this List to jsp and save it. I tried with the code below:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    logger.info("Welcome home! The client locale is {}.", locale);

    /*
    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
    
    String formattedDate = dateFormat.format(date);
    
    model.addAttribute("serverTime", formattedDate );
    */
    List<BulletinBoardList> result = sqlSession.selectList("board.getList");
    
    model.addAttribute("list", result);
    

    
    
    return "home";
}

Next, this code is for retrieving the List from controller:

<%@ page import com.heesu.third.BulletinBoardList, java.util.List %>
<% BulletinBoardList list = ${list} %>

But it never works.

1 Answers
Related