-
一只斗牛犬
非得报404错,在正常的项目不允许报错的User user = new User();if(id>0){user.setId(id);user.setRealName("张三");user.setSex(1);user.setBirthDay(new Date());}else{user=null;}
-
潇湘沐
123456789101112131415import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse; 。。。 @RequestMapping(value="/test2", produces="application/json;charset=UTF-8") @ResponseBody public Object test2(HttpServletRequest request,HttpServletResponse response) { Student a = new Student(); a.name="2222"; a.status="404"; response.setStatus(404); //在这里设置自定义HTTP状态 System.out.println(a); return a; }
-
aluckdog
非得报404错,在正常的项目不允许报错的User user = new User();if(id>0){user.setId(id);user.setRealName("张三");user.setSex(1);user.setBirthDay(new Date());}else{user=null;}