Answer the question
In order to leave comments, you need to log in
Goggle map?
Specialists and semi-specialists, I ask for help: in the JSP file I have a script that allows you to place marks on the Google map:
var stationList = [
{"latlng":[43.00000000, 43.00000000], name:"Shinagawa Station", url:"/MastersServlet?action=listUser", address:"-----str"},
{"latlng":[43.00000000, 43.00000000], name:"Station", url:"../barber/beuaty/masterslist.jsp", address:"-----str" },
{"latlng":[43.00000000, 43.00000000], name:"Tokyo1 Station", url:"second.php", address:"----str"},
{"latlng":[43.00000000, 43.00000000], name:"Shinagawa1 Station", url:"second.php", address:"-----str"},
{"latlng":[43.00000000, 43.00000000], name:"Station", url:"second.php", address:"------str" },
{"latlng":[43.00000000, 43.00000000], name:"Tokyo2 Station", url:"second.php", address:"----- str"},
{"latlng":[43.00000000, 43.00000000], name:"Shinagawa2 Station", url:"second.php", address:"-----str"},
];
<code lang="javascript">
<c:forEach items="${users}" var="user">
var stationList = [
{"latlng":[<c:out value="${user.lat}" />, <c:out value="${user.lng}" />], name:"<c:out value="${user.name}" />", url:"<c:out value="${user.url}" />", address:"<c:out value="${user.addres}" />"},
</с:forEach>
</code>
public List<User> getAllUsers() {
List<User> users = new ArrayList<User>();
try {
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select * from table");
while (rs.next()) {
User user = new User();
user.setName(rs.getString("name"));
user.setAddres(rs.getString("addres"));
user.setLat(rs.getString("lat"));
user.setLng(rs.getString("lng"));
/* user.setMasteregistration(rs.getDate("masterregistration"));*/
users.add(user);
}
} catch (SQLException e) {
e.printStackTrace();
}
return users;
}
Answer the question
In order to leave comments, you need to log in
The loop must be done inside the formed array.
And where is the closing tag of the cycle?
And why multiple lines?
In the loop body, form a string with coordinates.
Those. you need to write it once, it will just be repeated / displayed several times.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question