{"id":15345817,"url":"https://github.com/chucheng92/mariomvc","last_synced_at":"2025-04-06T11:13:21.439Z","repository":{"id":95899401,"uuid":"52144562","full_name":"chucheng92/MarioMVC","owner":"chucheng92","description":":smiley:Java实现的简洁MVC框架, 如何使用 ==\u003e","archived":false,"fork":false,"pushed_at":"2018-04-17T03:19:18.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T16:49:10.377Z","etag":null,"topics":["java-mvc"],"latest_commit_sha":null,"homepage":"https://github.com/Lemonjing/MarioSample","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chucheng92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-20T08:45:01.000Z","updated_at":"2020-08-14T02:56:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"8494ae3b-3504-4443-916e-8b474c29e0d2","html_url":"https://github.com/chucheng92/MarioMVC","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.10526315789473684","last_synced_commit":"5c26d484a7da0efda49cd502f240ce6569414f4d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chucheng92%2FMarioMVC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chucheng92%2FMarioMVC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chucheng92%2FMarioMVC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chucheng92%2FMarioMVC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chucheng92","download_url":"https://codeload.github.com/chucheng92/MarioMVC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471524,"owners_count":20944158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java-mvc"],"created_at":"2024-10-01T11:16:01.103Z","updated_at":"2025-04-06T11:13:21.353Z","avatar_url":"https://github.com/chucheng92.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 如何设计一个JavaWeb MVC框架\n\n通过使用Java语言实现一个完整的框架设计，这个框架中主要内容有第一小节介绍的Web框架的结构规划，例如采用MVC模式来进行开发，程序的执行流程设计等内容；第二小节介绍框架的第一个功能：路由，如何让访问的URL映射到相应的处理逻辑；第三小节介绍处理逻辑，如何设计一个公共的 `调度器`，对象继承之后处理函数中如何处理response和request；第四小节至第六小节介绍如何框架的一些辅助功能，例如配置信息，数据库操作等；最后介绍如何基于Web框架实现一个简单的增删改查，包括User的添加、修改、删除、显示列表等操作。\n\n\n### MarioMVC 框架结构\n\ncommon包：主要包括框架初始化接口 预定义常量 全局配置单例 线程上下文 前端过滤器\n\nconfig包：配置加载器\n\nrender包：视图渲染类\n\ndb包：采用sql2o的数据库操作\n\nroute包：路由类 路由管理类 路由匹配类\n\nservelet包：对HttpRequest和HttpResponse简单封装\n\nutil包：路径处理工具、异常处理工具、反射工具\n\n### MarioMVC 请求流程\n\n准备工作：\n\n- 开发者编写Model类和View层\n\n- 编写Controller\n\n- 对web.xml配置（主要是前端过滤器和框架的初始化）其中前端过滤器为MVC框架的全限定名，拦截请求根据开发者需求自定义；框架初始化需要开发者实现Bootstrap初始化接口并载入路由，当然还有数据库连接的初始化\n\n- 配置POM依赖：MVC-Mario、jstl、sql2o、jdbc驱动\n\n请求流程：\n读取Web.xml中的配置初始化框架和数据库连接 -\u003e 请求到达 -\u003e filter拦截根据请求的uri进行路由选择 -\u003e 请求分发 -\u003e 定位到Controller中具体方法\n\n简单来说：匹配在Path上，执行靠Method，处于某个Controller中，同SpringMVC的机制类似。不同点在于SpringMVC使用前端控制器DispatcherServlet来实现请求的分发。\n\n### 不足\n\n没有加入IOC、AOP\n\n\n![](http://i.imgur.com/QH8SRfB.png)\n\n- 项目源码：[https://github.com/Lemonjing/MarioMVC](https://github.com/Lemonjing/MarioMVC)\n- 示例代码：[https://github.com/Lemonjing/MarioSample](https://github.com/Lemonjing/MarioSample)\n\n那么，现在[开始](docs/index.md)吧~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchucheng92%2Fmariomvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchucheng92%2Fmariomvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchucheng92%2Fmariomvc/lists"}