从Spring控制器发送到JSP时,列表不可见

时间:2018-02-04 14:43:12

标签: spring jsp

首先,这是我的控制器:

@RequestMapping(method = RequestMethod.POST, value = "/searchMedia")
public ModelAndView searchAndDisplayResource(@RequestParam String name,   @RequestParam String type){

    ResultSet rs;
    DBQuery dbQuery = new DBQuery();
    rs = dbQuery.getMediaInfo(name, type);
    if (!rs.isBeforeFirst()) {
    //  String mediaInfoJson = omdbApiHelper.getMediaDetail(name);
        //parse the json, create the mio and persist
        return null;
    } else {
        MediaInfoHelper mediaInfoHelper = new MediaInfoHelper();
        ArrayList<MediaInfoModel> mediaList = mediaInfoHelper.getQueriedMediaList(rs);
        System.out.println(mediaList.size());
        ModelAndView mav = new ModelAndView("mediainfo");
        mav.addObject("mediaList",mediaList);
        return mav;
    }

}

这是我的JSP:

    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
    <c:if test="${not empty lists}">

        <ul>
            <c:forEach var="mediaInfo" items="${mediaList}">
                <li>${mediaInfo.name}</li>
            </c:forEach>
        </ul>

    </c:if>
</body>
</html>

对于我正在尝试的查询,列表的大小为1。问题是列表没有显示出来。有人可以告诉我哪里出错了吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试更改:

<c:if test="${not empty lists}">

要:

<c:if test="${not empty mediaList}">