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());
没看到你声明model这个变量
既然你是servlet向jsp传参,为啥还要用model啊,直接 往session里放就可以了啊
比如
HttpSession session = req.getSession()
session.setAttribute("message", AQIarray.toString())