try{ Integer adminID = Integer.parseInt(adminId); XxAdmin admin = adminRepository.findOne(adminID); model.addAttribute("admin",admin); }catch (Exception e){ StackTraceElement stackTraceElement = e.getStackTrace()[0]; String errorMsg = "文件名:"+stackTraceElement.getFileName()+ "\r\n类名:"+stackTraceElement.getClassName()+ "\r\n方法名:"+stackTraceElement.getMethodName()+ "\r\n抛出异常行号:"+stackTraceElement.getLineNumber()+ "\r\n异常信息:"+ e.getMessage(); System.out.println(errorMsg); logger.error(errorMsg); }