foreach循环在javascript中不起作用

时间:2014-12-09 07:32:51

标签: java javascript jsp foreach jstl

foreach循环在jsp page.help中的javascript中无效。提前任意body.thanks。

<script type="text/javascript">
var lineCoordinates = [
             < c:forEach items = "${mapBean.googleMapLocations}" var = "googleLocation"  varStatus = "status" >
             ['${googleLocation.latitude}', '${googleLocation.longitude}']
             < c:if test = "${!status.last}" >
                    ,
                    < /c:if>
                    < /c:forEach>
            ];
alert(lineCoordinates);
</script>

mapBean managedbean:

 public java.util.List<Components> getGoogleMapLocations() {
        System.out.println("entered");
        SessionFactory sf = HibernateUtil.getSessionFactory();
        Session sess = sf.openSession();
        Query q = sess.createQuery("from Components");
        java.util.List l = q.list();
        Iterator it = l.iterator();
        while (it.hasNext()) {
            Components cmp = (Components) it.next();
            System.out.println("Latitude" + cmp.getLatitude() + "longitude" + cmp.getLongitude() );
        }
        sess.close();
        return l;
    }

0 个答案:

没有答案