<c:foreach>标记无法正常工作</c:foreach>

时间:2015-03-06 08:36:20

标签: java jsp

我的java代码是

@RequestMapping(value = "/common_views/view-lecturer-Projects")
    public String viewLecturerProjects(HttpServletRequest request, ModelMap map) {
        String userId=request.getParameter("userId");
        map.put("viewUserProjects", projectService.findProjectByUserId(Long.valueOf(userId)));
        System.out.println("=================>Project type= "+projectService.findProjectByUserId(Long.valueOf(userId)).getTypeOfProject());
        System.out.println("=================>Project title= "+projectService.findProjectByUserId(Long.valueOf(userId)).getTitleOfProject());
       // System.out.println("===============>Project= "+(projectService.findProjectByUserId(Long.valueOf(userId))).get(0).getTitleOfProject());
        return "common_views/viewLecturerProjects";
    }

页面/ common_views / view-讲师 - 项目是

 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Index - SIL-Bridge</title>
</head>
<body>
<jsp:include page="/WEB-INF/includes/header.jsp" flush="true" />
<jsp:include page="/WEB-INF/includes/menubar.jsp" flush="false" />
<div class="main main-inner">
    <div class="container">
        <div class="row">
            <div class="span12">
                <div class="widget widget-nopad">
                    <div class="widget-header"><i class="icon-list-alt"></i>

                        <h3>Home</h3>
                    </div>
                    <!-- /widget-header -->
                    <div class="widget-content">
                        <form id="view-all-lecturer-project" class="form-horizontal">
                            <fieldset>
                                <table id="viewAllLecturersProject" class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th>Title of the project</th>
                                        <th>Type of the project</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${viewUserProjects}" var="viewUserProject">
                                        <tr>
                                            <td><a href="/sil-web/common_views/view-lecturer-project-details?projectId=${viewUserProject.projectId}"><c:out value="${viewUserProject.titleOfProject}"/></a></td>
                                            <td><c:out value="${viewUserProject.typeOfProject}"/></td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>


                                </table>

                                <br/><br/>


                            </fieldset>
                        </form>
                    </div>
                </div>
                <!-- /widget -->
            </div>
        </div>
        <!-- /row -->
    </div>
    <!-- /container -->
</div>
<!-- /main-inner -->

</body>
</html>

在此页面中,$ {viewUserProject.titleOfProject},$ {viewUserProject.typeOfProject}`在此页面中不显示,但java代码打印值

1 个答案:

答案 0 :(得分:-1)

在jsp上编写以下taglib import语句。

<%@ taglib prefix="c" 
       uri="http://java.sun.com/jsp/jstl/core" %>

如果您没有JARL用于JSTL,请从下面的URL下载并将该JAR放入项目的构建路径中。

http://www.oracle.com/technetwork/java/index-jsp-135995.html