HTTP状态 500 - 内部服务器错误
类型 异常报告
消息 在 [46] 行处理 [map1.jsp] 时发生异常
描述 服务器遇到一个意外的情况,阻止它完成请求。
例外情况
org.apache.jasper.JasperException: 在 [46] 行处理 [map1.jsp] 时发生异常
43: var markerArr = [];
44: var obj={};
45: <%List<Station> list = (List<Station>) request.getAttribute("stations");
46: for (int i = 0; i < list.size(); i++) {
47: Station s = list.get(i);
48: String latitude = s.getLatitude();
49: String longitude = s.getLongitude();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:626)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
根本原因。
java.lang.NullPointerException
org.apache.jsp.map1_jsp._jspService(map1_jsp.java:168)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
):注意 主要问题的全部 stack 信息可以在 server logs 里查看
Apache Tomcat/9.0.37
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ page import="com.map.pojo.Station"%>
<%@ page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
body, html, #container {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
font-family: "微软雅黑";
}
</style>
<script
src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=f7VQvU1BbyNNGfPzDIRGybKXpn3SFnat"></script>
</head>
<body>
<div id="container"></div>
<%--
<c:forEach var="s" items="${stations}" varStatus="status">
名称:${s.name},经度:${s.longitude},纬度:${s.latitude}</br>
</c:forEach> --%>
<script type="text/javascript">
var map = new BMapGL.Map('container');
map.centerAndZoom(new BMapGL.Point(119.16816, 36.714439), 12);
map.enableScrollWheelZoom(true);
var markerArr = [];
var obj={};
<%List<Station> list = (List<Station>) request.getAttribute("stations");
for (int i = 0; i < list.size(); i++) {
Station s = list.get(i);
String latitude = s.getLatitude();
String longitude = s.getLongitude();
String name = s.getName();%>
var obj=["<%=longitude%>","<%=latitude%>","地址:"+'<%=name%>'];
markerArr.push(obj);
//alert(markerArr);
//alert('<%=name%>'+","+'<%=latitude%>'+","+'<%=longitude%>
');
<%}%>
for (var i = 0; i < markerArr.length; i++) {
(function(x) {
var marker = new BMapGL.Marker(new BMapGL.Point(
markerArr[x][0], markerArr[x][1]));
var addres = markerArr[x][2];
map.addOverlay(marker);
var opts = {
width : 150,
height : 100,
title : "所在单位",
enableMessage : true,
};
var content = "<br/>" + addres;
var info_Window = new BMapGL.InfoWindow(content, opts);
marker.addEventListener("click", function() {
this.openInfoWindow(info_Window);
});
map.addOverlay(marker);
})(i);
}
map.addControl(new BMapGL.NavigationControl());
</script>
</body>
</html>