Java的异常捕获该怎么写?
各位大大好.
问题如下:
我在写一个Spring mvc项目, 在dao层类中写了一个可能会执行失败的方法:
/** * 删除 */public void remove(int id) throws Exception { Session session = getSession(); session.delete(session.load(Usergroup.class, id));} /** * 删除 */ public Map<String, Object> remove(int id) { Map<String, Object> map = new HashMap<String, Object>(); try { userGroupDao.remove(id); map.put("isSuccess", true); } catch (Exception e) { map.put("isSuccess", false); map.put("errorMsg", e.getMessage()); } return map; }