{"id":22560379,"url":"https://github.com/akuma/demo-springmvc","last_synced_at":"2025-03-28T12:13:55.683Z","repository":{"id":3464450,"uuid":"4518819","full_name":"akuma/demo-springmvc","owner":"akuma","description":"demo-springmvc","archived":false,"fork":false,"pushed_at":"2013-06-08T04:19:17.000Z","size":1932,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T12:41:24.168Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/akuma.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}},"created_at":"2012-06-01T11:13:06.000Z","updated_at":"2013-06-08T04:19:18.000Z","dependencies_parsed_at":"2022-08-28T21:10:17.751Z","dependency_job_id":null,"html_url":"https://github.com/akuma/demo-springmvc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akuma%2Fdemo-springmvc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akuma%2Fdemo-springmvc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akuma%2Fdemo-springmvc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akuma%2Fdemo-springmvc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akuma","download_url":"https://codeload.github.com/akuma/demo-springmvc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246026111,"owners_count":20711581,"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":[],"created_at":"2024-12-07T21:13:25.538Z","updated_at":"2025-03-28T12:13:55.658Z","avatar_url":"https://github.com/akuma.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"The Spring MVC Demo\n================================\n\nThis is a webapp for demonstrating Spring MVC Framework.\n\n如何在本地运行系统\n----------------\n执行 maven 任务：clean tomcat7:run -Dwebapp.port=8080（这里指定了 8080 端口）\n\ndemo 功能查看\n------------\n* 演示 ajax 调用：/demo/ajax/\n* 演示 freemarker 模版使用：/demo/freemarker/\n* 演示系统信息提示：/demo/message/\n\n命名规则\n------------\n1. CSS: 小写字母，多个单词采用 “-” 分割，例如：icon-trash\n2. JavaScript: 采用驼峰命名\n3. Controller: XxxController (QuestionController, QuestionInputControll)\n4. Controller method: viewXxx, addXxxx, modifyXxx, removeXxx, etc\n5. Service: XxxService, XxxServiceImpl (StudentService, StudentServiceImpl)\n6. Service method: getXxx, countXxx, addXxx, modifyXxx, removeXxx, etc\n7. Dao: XxxDao (StudentDao)\n8. Dao method: find, findByXxx, countByXxx, insert, update, updateXxx, delete, deleteByXxx\n\n前端 \u0026 视图层\n------------\n\n* html 页面采用 html5 的写法，比如：\n  * link、input 等元素不需要闭合：`\u003cinput name=\"test\" type=\"text\"\u003e`\n  * 按钮使用 button 元素定义：`\u003cbutton\u003e我是一个按钮\u003c/button\u003e`\n  * script 元素可以简写为：`\u003cscript src=\"...引用文件...\"\u003e\u003c/script\u003e、\u003cscript\u003e...代码...\u003c/script\u003e`\n  * 避免在 html 元素中直接写事件代码的方式，采用 jQuery 的事件绑定，降低 js 和 html 之间的代码耦合。\n* 充分使用 jQuery 来减少 js 中的重复代码。\n* 避免在页面上直接编写大量 js 代码，如果代码超过 20 行，就应该将代码抽取到独立的 js 文件中。\n* 反复用到的相似的 html 代码，应该用 freemarker 宏来实现，这样可以减少前端的重复代码。\n* 实现某个 Controller 方法的时候，注意控制台输出的 SQL 情况，尽量减少 SQL 查询和避免重复查询。\n* 一般添加、修改、更新页面局部数据内容等功能都使用 ajax 方式实现，同时根据不同的场景选择最佳的数据返回格式（json、html）。\n\n业务层\n------------\n\n* 注意 Service 方法的可重用性，在写新的方法之前先看看有没有已经存在的方法。\n* Service 中引用其他 Service 或 DAO 时，优先使用 Service。\n* 一般情况下 Service 数量小于 DAO 数量，因为一个 Service 包含了某种业务的操作，可能会用到多个 DAO/Service。\n* 充分利用 commons 中的工具类来解决问题。\n  * 字符串操作用 StringUtils\n  * 日期操作用 DateUtils、DateFormatUtils\n  * JavaBean 中属性方面的反射操作用 BeanUtils\n\n数据库层\n------------\n\n* 原则上每个表一个 DAO 类，一般情况下一个 DAO 类不能操作多个表。\n* 除非 MyBatisBasicDao 中缺少可以使用的方法，否则不要新增方法。\n* 尽量使用简洁的 SQL 查询，使 SQL 覆盖数据库索引。\n* 避免复杂的多表连接查询，改由程序实现连接。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakuma%2Fdemo-springmvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakuma%2Fdemo-springmvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakuma%2Fdemo-springmvc/lists"}