# crowdfunding **Repository Path**: hanj98/crowdfunding ## Basic Information - **Project Name**: crowdfunding - **Description**: 众筹网 - **Primary Language**: Java - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-12-08 - **Last Updated**: 2023-02-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: SSM, Java, JavaScript ## README # 众筹网 #### 介绍 本仓库含有完整的代码以及详尽的代码注释(包括**sql语句**),pdf文档等,如有需要的文件,可发[**邮件**](mailto:hanj.cn@outlook.com)提醒我补充 #### 结构 - crowdfunding01-admin-parent - crowdfunding02-admin-webui - crowdfunding03-admin-component - crowdfunding04-admin-entity - crowdfunding05-common-util - crowdfunding06-common-reverse #### 截图与部分代码 部分代码: **generatorConfig.xml** ```xml ``` **CrowdExceptionResolver.java** ```java /** * 基于注解的自定义异常解析器 */ @ControllerAdvice // 表示这个一个基于注解的,处理异常的类 public class CrowdExceptionResolver { /** * The Logger. */ Logger logger = LoggerFactory.getLogger(this.getClass()); /** * 捕获异常并返回异常信息 * * @param exception 异常 * @param request 请求,用来判断是否为ajax请求 * @param resp 响应,用来回写数据给页面 * @return 模型视图 model and view * @throws IOException IO异常 */ @ExceptionHandler(value = Exception.class) // 表示这个方法能处理的异常类型 public ModelAndView ExceptionResolver( // 实际捕获的异常 Exception exception, // 当前请求 HttpServletRequest request, // 响应对象 HttpServletResponse resp ) throws IOException { // 打印异常信息 exception.printStackTrace(); // 模型和视图 ModelAndView modelAndView = new ModelAndView(); // 视图名 String viewName = "system-error"; logger.warn("异常的类型 = " + exception.getClass().getSimpleName() + " 描述 = " + exception.getMessage()); // 判断异常类型 if (exception instanceof RegisterFailedException) { viewName = "admin-add"; } if (exception instanceof AccessForbiddenException) { viewName = "admin-login"; } return commonResolver(viewName, exception, request, resp, modelAndView); } private ModelAndView commonRequestResolver(String viewName, ModelAndView modelAndView, Exception exception) { modelAndView.setViewName(viewName); modelAndView.addObject(CrowdConstant.ATTR_NAME_EXCEPTION, exception); return modelAndView; } private void ajaxRequestResolver(Exception exception, HttpServletResponse resp) { // 如果是Ajax请求,创建ResultEntity对象,传入message ResultEntity resultEntity = ResultEntity.failed(exception.getMessage()); // 创建Gson对象 Gson gson = new Gson(); // 将resultEntity转为json String resultEntity_json = gson.toJson(resultEntity); // 将json返回给页面 try { resp.getWriter().write(resultEntity_json); } catch (IOException e) { e.printStackTrace(); } } private ModelAndView commonResolver( // 视图名 String viewName, // 实际捕获的异常 Exception exception, // 当前请求 HttpServletRequest request, // 响应对象 HttpServletResponse resp, // 模型和视图 ModelAndView modelAndView ) { // 判断当前请求类型 Boolean isAjaxRequest = CrowdUtils.isAjaxRequest(request); if (isAjaxRequest) { // 如果是ajax请求 ajaxRequestResolver(exception, resp); return null; } // 不是Ajax请求,返回模型和视图 return commonRequestResolver(viewName, modelAndView, exception); } } ``` 列举一下几个页面作为展示 **登录页面** ![image-20211208124001074](README.assets/image-20211208124001074.png) **用户列表** ![image-20211208124314227](README.assets/image-20211208124314227.png) **新增页面** ![image-20211208124406403](README.assets/image-20211208124406403.png) #### 联系方式 [点此](mailto:hanj.cn@outlook.com) #### 写在最后 感谢努力的我自己