巴啦啦老魔王 2019-04-17 12:53 采纳率: 0%
浏览 291

idea使用new Gson().toGson() http状态码报500错误,

private void userShowInfor(HttpServletRequest req,HttpServletResponse resp)throws IOException,ServletException{
//处理请求
//调用service,因为查询所有数据 所以返回List
List lu = ls.userShowService();

    System.out.println("list输出:"+lu);
    System.out.println("list输出:"+lu.get(0));


    resp.getWriter().write(new Gson().toJson(lu));
    if(lu!=null){
        req.setAttribute("lu",lu);

    }
}
    导入了jar包,在eclipse使用这句话没问题,但是同样的代码放到idea上就会500
  • 写回答

1条回答 默认 最新

  • weixin_55422351 2023-04-06 22:22
    关注

    gson jar包不能直接放在和src同级的lib文件夹里,一定要在web=>WEB-INF=>lib里。我也不知道原理是啥

    评论

报告相同问题?