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

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