问题遇到的现象和发生背景
servlet向jsp传值的时候,model.addAttribute()报错,model下面红线:model cannot be resolved
用代码块功能插入代码,请勿粘贴截图
String city = request.getParameter("city");
UserDaoimpl dao = new UserDaoimpl();
ArrayList<User> AQIlist = dao.findBycitytoAQI(city);
ArrayList<User> timelist = dao.findBycitytotime(city);
JSONArray AQIarray = new JSONArray();
for(User a : AQIlist){
JSONObject joa = new JSONObject();
joa.put("AQI", a.getAQI());
AQIarray.put(joa);
}
JSONArray timearray = new JSONArray();
for(User a : timelist){
JSONObject jot = new JSONObject();
jot.put("time", a.getTime());
timearray.put(jot);
}
model.addAttribute("message", AQIarray.toString());