c:foreach标记不适用于javascript jsp中的GoogleMap

c:foreach标记不适用于javascript jsp中的GoogleMap,javascript,google-maps,jsp,google-maps-api-3,foreach,Javascript,Google Maps,Jsp,Google Maps Api 3,Foreach,我必须使用fatbase中的纬度和经度值来显示GoogleMap,但使用c:foreach标记无法工作,但我不知道c:foreach标记有什么问题。jsp页面和managedbean的代码如下所示: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <%@ taglib prefix="c" uri="http://java.sun.co

我必须使用fatbase中的纬度和经度值来显示GoogleMap,但使用c:foreach标记无法工作,但我不知道c:foreach标记有什么问题。jsp页面和managedbean的代码如下所示:

   <%@page contentType="text/html" pageEncoding="UTF-8"%>
        <!DOCTYPE html>
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
        <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
        <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
        <html> 
            <head> 
                <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
                <title>Google Maps Multiple Markers</title> 
                <script src="http://maps.google.com/maps/api/js?sensor=false"
                type="text/javascript"></script>
                <script type="text/javascript" src="js/jquery-2.1.1.js"></script>

            </head> 
            <body>
                <!--<div id="load_me">Current Time :<%= new java.util.Date() %></div>-->
                <input type="button" onclick="mapRefresh();" value="Refresh" class="button" />
                <div><br/></div>
                <div id="map" style="width: 1300px; height: 600px;"></div>

        <!--        <script type="text/javascript">
                    //alert("my alert");
                    var auto_refresh = setInterval(
                            function()
                            {
                                // alert("alert");
                                $('#load_me').load('mapview.jsp').fadeIn("slow");
                            }, 5000); // autorefresh the content of the div after
                    //every 10000 milliseconds(10sec)
                </script>-->
                <script type="text/javascript">

                    //alert("hello");
                    var locations = [
                    <c:forEach items="${mapBean.googleMapLocations}" var="googleLocation"  varStatus ="status">
                        ['${googleLocation.latitude}', '${googleLocation.longitude}']
                        <c:if test="${!status.last}">
                        ,
                        </c:if>
                    </c:forEach>
                    ];
                   alert(locations);
         var map = new google.maps.Map(document.getElementById('map'), {
                        zoom: 10,
                        center: new google.maps.LatLng("${mapBean.centerLatitude}", "${mapBean.centerLongitude}"),
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    });
                    var infowindow = new google.maps.InfoWindow();
                    var marker, i;
                    for (i = 0; i < locations.length; i++) {
                        marker = new google.maps.Marker({
                            position: new google.maps.LatLng(locations[i][0], locations[i][1]),
                            map: map
                        });
                        google.maps.event.addListener(marker, 'click', (function(marker, i) {
                            return function() {
                                infowindow.setContent(locations[i][0]);
                                infowindow.open(map, marker);
                            }
                        })(marker, i));
                    }
         </script>
        <table>
                    <c:forEach var="googleLocation" items="${mapBean.googleMapLocations}">
                        <tr><td>${googleLocation.latitude}</td><td>${googleLocation.longitude}</td></tr>  
                    </c:forEach>
                    CENTER<tr><td>${mapBean.centerLatitude}</td><td>${mapBean.centerLongitude}</td></tr>
                </table>

            </body>
        </html>

Managedbean Code:
public class MapBean implements java.io.Serializable {

 private double centerLatitude;
    private double centerLongitude;
 public java.util.List<Components> getGoogleMapLocations() {
        SessionFactory sf = HibernateUtil.getSessionFactory();
        Session sess = sf.openSession();
        Query q = sess.createQuery("from Components");
        java.util.List l = q.list();
        sess.close();
        return l;
    }
}

谷歌地图多个标记

//警惕(“你好”); 变量位置=[ ['${googleLocation.latitude}','${googleLocation.latitude}'] , ]; 警报(地点); var map=new google.maps.map(document.getElementById('map'){ 缩放:10, 中心:新的google.maps.LatLng(${mapBean.centerLatitude},“${mapBean.centerLongitude}”), mapTypeId:google.maps.mapTypeId.ROADMAP }); var infowindow=new google.maps.infowindow(); var标记,i; 对于(i=0;i
我想这就是您需要在c:foreach标记中包含的内容