-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.json
1 lines (1 loc) · 490 KB
/
db.json
1
{"meta":{"version":1,"warehouse":"2.2.0"},"models":{"Asset":[{"_id":"themes/next/source/404.html","path":"404.html","modified":1,"renderable":1},{"_id":"themes/next/source/favicon.ico","path":"favicon.ico","modified":1,"renderable":1},{"_id":"themes/next/source/css/main.styl","path":"css/main.styl","modified":1,"renderable":1},{"_id":"themes/next/source/images/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67.png","path":"images/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67.png","modified":1,"renderable":1},{"_id":"themes/next/source/images/avatar.gif","path":"images/avatar.gif","modified":1,"renderable":1},{"_id":"themes/next/source/images/avatar.png","path":"images/avatar.png","modified":1,"renderable":1},{"_id":"themes/next/source/images/cc-by-nc-nd.svg","path":"images/cc-by-nc-nd.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/cc-by-nc-sa.svg","path":"images/cc-by-nc-sa.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/cc-by-nc.svg","path":"images/cc-by-nc.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/cc-by-sa.svg","path":"images/cc-by-sa.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/cc-by-nd.svg","path":"images/cc-by-nd.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/cc-by.svg","path":"images/cc-by.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/forkme_left_green_007200.png","path":"images/forkme_left_green_007200.png","modified":1,"renderable":1},{"_id":"themes/next/source/images/cc-zero.svg","path":"images/cc-zero.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/loading.gif","path":"images/loading.gif","modified":1,"renderable":1},{"_id":"themes/next/source/images/placeholder.gif","path":"images/placeholder.gif","modified":1,"renderable":1},{"_id":"themes/next/source/images/quote-l.svg","path":"images/quote-l.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/quote-r.svg","path":"images/quote-r.svg","modified":1,"renderable":1},{"_id":"themes/next/source/images/searchicon.png","path":"images/searchicon.png","modified":1,"renderable":1},{"_id":"themes/next/source/images/wechat-qcode.jpg","path":"images/wechat-qcode.jpg","modified":1,"renderable":1},{"_id":"themes/next/source/images/wechat-reward-image.jpg","path":"images/wechat-reward-image.jpg","modified":1,"renderable":1},{"_id":"themes/next/source/images/wechat.png","path":"images/wechat.png","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/affix.js","path":"js/src/affix.js","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/bootstrap.js","path":"js/src/bootstrap.js","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/hook-duoshuo.js","path":"js/src/hook-duoshuo.js","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/motion.js","path":"js/src/motion.js","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/post-details.js","path":"js/src/post-details.js","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/scrollspy.js","path":"js/src/scrollspy.js","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/utils.js","path":"js/src/utils.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fastclick/LICENSE","path":"vendors/fastclick/LICENSE","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fastclick/README.md","path":"vendors/fastclick/README.md","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fastclick/bower.json","path":"vendors/fastclick/bower.json","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/HELP-US-OUT.txt","path":"vendors/font-awesome/HELP-US-OUT.txt","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/bower.json","path":"vendors/font-awesome/bower.json","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/velocity/bower.json","path":"vendors/velocity/bower.json","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/velocity/velocity.min.js","path":"vendors/velocity/velocity.min.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/velocity/velocity.ui.js","path":"vendors/velocity/velocity.ui.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/velocity/velocity.ui.min.js","path":"vendors/velocity/velocity.ui.min.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/jquery_lazyload/CONTRIBUTING.md","path":"vendors/jquery_lazyload/CONTRIBUTING.md","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/jquery_lazyload/README.md","path":"vendors/jquery_lazyload/README.md","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/jquery_lazyload/bower.json","path":"vendors/jquery_lazyload/bower.json","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/jquery_lazyload/jquery.scrollstop.js","path":"vendors/jquery_lazyload/jquery.scrollstop.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/jquery_lazyload/jquery.lazyload.js","path":"vendors/jquery_lazyload/jquery.lazyload.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/jquery/index.js","path":"vendors/jquery/index.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/blank.gif","path":"vendors/fancybox/source/blank.gif","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/fancybox_loading.gif","path":"vendors/fancybox/source/fancybox_loading.gif","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/[email protected]","path":"vendors/fancybox/source/[email protected]","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/fancybox_overlay.png","path":"vendors/fancybox/source/fancybox_overlay.png","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/fancybox_sprite.png","path":"vendors/fancybox/source/fancybox_sprite.png","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/[email protected]","path":"vendors/fancybox/source/[email protected]","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/jquery.fancybox.css","path":"vendors/fancybox/source/jquery.fancybox.css","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/jquery.fancybox.js","path":"vendors/fancybox/source/jquery.fancybox.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/jquery.fancybox.pack.js","path":"vendors/fancybox/source/jquery.fancybox.pack.js","modified":1,"renderable":1},{"_id":"themes/next/source/js/src/schemes/pisces.js","path":"js/src/schemes/pisces.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fastclick/lib/fastclick.js","path":"vendors/fastclick/lib/fastclick.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fastclick/lib/fastclick.min.js","path":"vendors/fastclick/lib/fastclick.min.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.woff2","path":"vendors/font-awesome/fonts/fontawesome-webfont.woff2","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/css/font-awesome.min.css","path":"vendors/font-awesome/css/font-awesome.min.css","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/css/font-awesome.css","path":"vendors/font-awesome/css/font-awesome.css","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/css/font-awesome.css.map","path":"vendors/font-awesome/css/font-awesome.css.map","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/ua-parser-js/dist/ua-parser.min.js","path":"vendors/ua-parser-js/dist/ua-parser.min.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/ua-parser-js/dist/ua-parser.pack.js","path":"vendors/ua-parser-js/dist/ua-parser.pack.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/fonts/FontAwesome.otf","path":"vendors/font-awesome/fonts/FontAwesome.otf","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.eot","path":"vendors/font-awesome/fonts/fontawesome-webfont.eot","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.woff","path":"vendors/font-awesome/fonts/fontawesome-webfont.woff","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/velocity/velocity.js","path":"vendors/velocity/velocity.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/helpers/fancybox_buttons.png","path":"vendors/fancybox/source/helpers/fancybox_buttons.png","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-buttons.css","path":"vendors/fancybox/source/helpers/jquery.fancybox-buttons.css","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-buttons.js","path":"vendors/fancybox/source/helpers/jquery.fancybox-buttons.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-media.js","path":"vendors/fancybox/source/helpers/jquery.fancybox-media.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-thumbs.css","path":"vendors/fancybox/source/helpers/jquery.fancybox-thumbs.css","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-thumbs.js","path":"vendors/fancybox/source/helpers/jquery.fancybox-thumbs.js","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.ttf","path":"vendors/font-awesome/fonts/fontawesome-webfont.ttf","modified":1,"renderable":1},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.svg","path":"vendors/font-awesome/fonts/fontawesome-webfont.svg","modified":1,"renderable":1}],"Cache":[{"_id":"themes/next/.gitignore","hash":"c8d6a73b9e17f0f8a3716e4ada6960d3180425a6","modified":1515554419000},{"_id":"themes/next/.bowerrc","hash":"80e096fdc1cf912ee85dd9f7e6e77fd40cf60f10","modified":1515554419000},{"_id":"themes/next/.hound.yml","hash":"b76daa84c9ca3ad292c78412603370a367cc2bc3","modified":1515554419000},{"_id":"themes/next/.editorconfig","hash":"792fd2bd8174ece1a75d5fd24ab16594886f3a7f","modified":1515554419000},{"_id":"themes/next/.javascript_ignore","hash":"d619ee13031908cd72666e4ff652d2ea3483b1c3","modified":1515554419000},{"_id":"themes/next/.jshintrc","hash":"9928f81bd822f6a8d67fdbc909b517178533bca9","modified":1515554419000},{"_id":"themes/next/_config.yml","hash":"36b70a42109a1bab0b561348205c0427e6385d6a","modified":1515554419000},{"_id":"themes/next/bower.json","hash":"f89c6700a11d81e067cc97273ca6bf96cb88c8f9","modified":1515554419000},{"_id":"themes/next/gulpfile.coffee","hash":"26e5b1b945704c8bc78b928feede895c4c111c95","modified":1515554419000},{"_id":"themes/next/package.json","hash":"63e9c0f1dd9e5d7f51b4ae383981ef939a2ed45d","modified":1515554420000},{"_id":"source/_posts/Github上搭建个人博客.md","hash":"deb7dec5cfca60b89b7dd150e43a4fa3b244e8ba","modified":1515554419000},{"_id":"source/_posts/JavaWeb开发掌握的技能.md","hash":"7912e117c82a23543d535d3f95bf9f15a11d2f4b","modified":1515554419000},{"_id":"source/_posts/Java中的字符串和表达式.md","hash":"1301e9f296e9cd45f3fa9a95df786c99e430679f","modified":1515554419000},{"_id":"source/_posts/SQL分组查询.md","hash":"294a23e4bc7c62475693ffea9d8f2ab011c7b020","modified":1515554419000},{"_id":"source/_posts/SQL子查询.md","hash":"0fcf1faedb29107a88ccd7287ddf9610ab2f5473","modified":1515554419000},{"_id":"source/_posts/SQL连接查询语法.md","hash":"9b47e0180f71119b9f93ddbe4b277941de221d02","modified":1515554419000},{"_id":"source/_posts/SSH2三大框架的整合.md","hash":"b3031d9360bbca021c6dcd8a9cd1d5ef36b3b9c2","modified":1515554419000},{"_id":"source/_posts/hello-world.md","hash":"92ae731c9aae1580987311a7d46102f36231e976","modified":1515554419000},{"_id":"source/_posts/java经典程序设计.md","hash":"9e43f0d240c2f5a0033769b382c7621f3504225b","modified":1515554419000},{"_id":"source/_posts/回首向来萧瑟萧瑟处,也无风雨也无晴——新的开始.md","hash":"b2b1a90e578350ffc05333835445fce7049eba79","modified":1515554419000},{"_id":"source/_posts/关于java-io-WriteAbortedException.md","hash":"d71b6d1de1b422ee307d624573b43bb45382e0a9","modified":1515554419000},{"_id":"source/_posts/条件查询和分页原理到底是怎么样的.md","hash":"e788475f4c718af9c71ce84801caa76c4fefd2cc","modified":1515554419000},{"_id":"source/_posts/文件上传(一).md","hash":"9f2da0f5ca6dfa5722673700de9426031dccf8fb","modified":1515554419000},{"_id":"source/_posts/Spring Boot运行原理.md","hash":"a5f203743790358aa152b5c2fd49615061ec5a1b","modified":1515556286000},{"_id":"source/_posts/文件上传.md","hash":"733b18966928a0d49511b2ee5a992b16d35c9975","modified":1515554419000},{"_id":"source/_posts/简单实例之文件下载.md","hash":"0befbcc92c024ff8397f4db5669d8013dce74eb5","modified":1515554419000},{"_id":"source/about/index.md","hash":"efbd2fa29feb26702b7af311718c27ca8512e91f","modified":1515565001000},{"_id":"source/_posts/简单实例之文件下载(二).md","hash":"7411c2f7080ad11771ac47dcca773c2918221c7a","modified":1515554419000},{"_id":"source/_posts/解析json对象.md","hash":"51b1e9d1514eeb9dd470c88d702e0eb024f005a5","modified":1515554419000},{"_id":"source/categories/index.md","hash":"1c9d5b86d7c7609d74a43b50cf7c35294e34a3a4","modified":1515554419000},{"_id":"source/_posts/条件查询和分页原理到底是怎么样的(二).md","hash":"5a9dfb66a7d14e2f71aa5a4da34e72a1584d0ae3","modified":1515554419000},{"_id":"source/tags/index.md","hash":"7c3871970ed19ef69bf9ad534d3c43ff149fd9a8","modified":1515554419000},{"_id":"themes/next/languages/de.yml","hash":"786afba25cfc98845a20d9901823ebeebcd1cbbf","modified":1515554419000},{"_id":"themes/next/languages/default.yml","hash":"9db835c0543ade5a89bc80ec5a898203227cf3d8","modified":1515554419000},{"_id":"themes/next/languages/en.yml","hash":"f03799cbdb5a33064ead080bcac4baca1f6bc5f9","modified":1515554419000},{"_id":"themes/next/languages/fr-FR.yml","hash":"1a084623c39de74301f3e92f9388a3a815a542ca","modified":1515554419000},{"_id":"themes/next/languages/id.yml","hash":"147c01e41b931085ad14250fa900c2249dcbbdd7","modified":1515554419000},{"_id":"themes/next/languages/ja.yml","hash":"a2c7b6301b5474aab798946fb700289df237c3cf","modified":1515554419000},{"_id":"themes/next/languages/ko.yml","hash":"ce8b047c89daae77c03482fc76f16ffec6bdbf2d","modified":1515554419000},{"_id":"themes/next/languages/ru.yml","hash":"cc7b964a46587aea0e57b0a5269d8fd25570858e","modified":1515554419000},{"_id":"themes/next/languages/pt-BR.yml","hash":"462aa865ca3d479bcf6b363cba61247b50f230ff","modified":1515554419000},{"_id":"themes/next/languages/zh-Hans.yml","hash":"a2d8411286c23b84da25e339a15a1c9aa3138b8d","modified":1515554419000},{"_id":"themes/next/languages/pt.yml","hash":"ca239b39bf65c9462e59d51b12f0fe566d453197","modified":1515554419000},{"_id":"themes/next/languages/zh-hk.yml","hash":"519ab3d817ec3bc5bfc91159c494b6b3c170bea7","modified":1515554419000},{"_id":"themes/next/languages/zh-tw.yml","hash":"6b1f345aaefc13e6723dc8a6741b59ac05c20dfd","modified":1515554419000},{"_id":"themes/next/layout/_layout.swig","hash":"9ebec55ce722355e2e6c3c47459dd2697f153b23","modified":1515554419000},{"_id":"themes/next/layout/category.swig","hash":"6422d196ceaff4220d54b8af770e7e957f3364ad","modified":1515554420000},{"_id":"themes/next/layout/index.swig","hash":"032db48f5a3cfd6f9692fd5952b8a7aea7dad3f7","modified":1515554420000},{"_id":"themes/next/layout/archive.swig","hash":"b5b59d70fc1563f482fa07afd435752774ad5981","modified":1515554420000},{"_id":"themes/next/layout/page.swig","hash":"8019d02232a6dd1a665b6a4d2daef8e5dd2f0049","modified":1515554420000},{"_id":"themes/next/scripts/merge-configs.js","hash":"0c56be2e85c694247cfa327ea6d627b99ca265e8","modified":1515554420000},{"_id":"themes/next/layout/tag.swig","hash":"07cf49c49c39a14dfbe9ce8e7d7eea3d4d0a4911","modified":1515554420000},{"_id":"themes/next/layout/post.swig","hash":"9fd52b04c2b59c7c9c7be6b73968eb4000d1dc77","modified":1515554420000},{"_id":"themes/next/source/404.html","hash":"bc926ec353cfd0eaef7f5102fbe17364db6bb8d1","modified":1515554420000},{"_id":"themes/next/test/.jshintrc","hash":"19f93d13d1689fe033c82eb2d5f3ce30b6543cc0","modified":1515554420000},{"_id":"themes/next/test/helpers.js","hash":"a1f5de25154c3724ffc24a91ddc576cdbd60864f","modified":1515554420000},{"_id":"themes/next/source/fonts/.gitkeep","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/test/intern.js","hash":"11fa8a4f5c3b4119a179ae0a2584c8187f907a73","modified":1515554420000},{"_id":"themes/next/source/favicon.ico","hash":"b4350b48a09a4b87f87138389ab9b12ee7fa0b8e","modified":1515554420000},{"_id":"themes/next/layout/_macro/post-collapse.swig","hash":"43c3433155ccd9abcbe7dce2e6bfa1f3a66af18b","modified":1515554419000},{"_id":"themes/next/layout/_macro/post.swig","hash":"832abfa49c208ad07f9835dd4bb4344c7ce64646","modified":1515554419000},{"_id":"themes/next/layout/_macro/sidebar.swig","hash":"1a77843ce5eac62151dc3d38f0a36c43e19e1a74","modified":1515554419000},{"_id":"themes/next/layout/_macro/wechat-subscriber.swig","hash":"14e785adeb0e671ba0ff9a553e6f0d8def6c670c","modified":1515554419000},{"_id":"themes/next/layout/_macro/reward.swig","hash":"37e5b7c42ec17b9b6b786c5512bcc481a21c974e","modified":1515554419000},{"_id":"themes/next/layout/_scripts/baidu-push.swig","hash":"82d060fe055d6e423bbc9199f82dfe5c68e74779","modified":1515554419000},{"_id":"themes/next/layout/_scripts/boostrap.swig","hash":"03aaebe9d50f6acb007ec38cc04acd1cfceb404d","modified":1515554419000},{"_id":"themes/next/layout/_scripts/commons.swig","hash":"766b2bdda29523ed6cd8d7aa197f996022f8fd94","modified":1515554419000},{"_id":"themes/next/layout/_scripts/vendors.swig","hash":"0b91cadecead8e0b5211cc42b085998d94af503a","modified":1515554420000},{"_id":"themes/next/layout/_partials/comments.swig","hash":"58fd826ca75b0cbc48b61a58da4b841e2fa34403","modified":1515554419000},{"_id":"themes/next/layout/_partials/duoshuo-hot-articles.swig","hash":"5d4638c46aef65bf32a01681495b62416ccc98db","modified":1515554419000},{"_id":"themes/next/layout/_partials/footer.swig","hash":"2dea4c6d1e37084e4923734a04f75576aef9559e","modified":1515554419000},{"_id":"themes/next/layout/_partials/head.swig","hash":"6b0c495b8154ef8b2d2cb0a554e164ff22cdc962","modified":1515554419000},{"_id":"themes/next/layout/_partials/header.swig","hash":"eb028685cb3c329537bbced06c063d23e6a33817","modified":1515554419000},{"_id":"themes/next/scripts/tags/center-quote.js","hash":"535fc542781021c4326dec24d8495cbb1387634a","modified":1515554420000},{"_id":"themes/next/scripts/tags/full-image.js","hash":"3acce36db0feb11a982c6c799aa6b6b47df2827c","modified":1515554420000},{"_id":"themes/next/scripts/tags/group-pictures.js","hash":"49252824cd53184dc9b97b2f2d87ff28e1b3ef27","modified":1515554420000},{"_id":"themes/next/layout/_partials/pagination.swig","hash":"9e8e21d194ef44d271b1cca0bc1448c14d7edf4f","modified":1515554419000},{"_id":"themes/next/layout/_partials/search.swig","hash":"011b9d6c9f0a2f4654908ea20b9391f9b7981271","modified":1515554419000},{"_id":"themes/next/source/css/main.styl","hash":"20702c48d6053c92c5bcdbc68e8d0ef1369848a0","modified":1515554420000},{"_id":"themes/next/source/images/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67.png","hash":"c00a90ad148620a49f0939fea2d55094047bce29","modified":1515554420000},{"_id":"themes/next/source/images/avatar.gif","hash":"264082bb3a1af70d5499c7d22b0902cb454b6d12","modified":1515554420000},{"_id":"themes/next/source/images/avatar.png","hash":"1bfdcfd509383a0324a45ae130981bf97f88ac99","modified":1515554420000},{"_id":"themes/next/source/images/cc-by-nc-nd.svg","hash":"c6524ece3f8039a5f612feaf865d21ec8a794564","modified":1515554420000},{"_id":"themes/next/source/images/cc-by-nc-sa.svg","hash":"3031be41e8753c70508aa88e84ed8f4f653f157e","modified":1515554420000},{"_id":"themes/next/source/images/cc-by-nc.svg","hash":"8d39b39d88f8501c0d27f8df9aae47136ebc59b7","modified":1515554420000},{"_id":"themes/next/source/images/cc-by-sa.svg","hash":"aa4742d733c8af8d38d4c183b8adbdcab045872e","modified":1515554420000},{"_id":"themes/next/source/images/cc-by-nd.svg","hash":"c563508ce9ced1e66948024ba1153400ac0e0621","modified":1515554420000},{"_id":"themes/next/source/images/cc-by.svg","hash":"28a0a4fe355a974a5e42f68031652b76798d4f7e","modified":1515554420000},{"_id":"themes/next/source/images/forkme_left_green_007200.png","hash":"c00a90ad148620a49f0939fea2d55094047bce29","modified":1515554420000},{"_id":"themes/next/source/images/cc-zero.svg","hash":"87669bf8ac268a91d027a0a4802c92a1473e9030","modified":1515554420000},{"_id":"themes/next/source/images/loading.gif","hash":"5fbd472222feb8a22cf5b8aa5dc5b8e13af88e2b","modified":1515554420000},{"_id":"themes/next/source/images/placeholder.gif","hash":"5fbd472222feb8a22cf5b8aa5dc5b8e13af88e2b","modified":1515554420000},{"_id":"themes/next/source/images/quote-l.svg","hash":"94e870b4c8c48da61d09522196d4dd40e277a98f","modified":1515554420000},{"_id":"themes/next/source/images/quote-r.svg","hash":"e60ae504f9d99b712c793c3740c6b100d057d4ec","modified":1515554420000},{"_id":"themes/next/source/images/searchicon.png","hash":"67727a6a969be0b2659b908518fa6706eed307b8","modified":1515554420000},{"_id":"themes/next/source/images/wechat-qcode.jpg","hash":"d2f738048eb32f36de8febdbfdd69b7c7522a707","modified":1515554420000},{"_id":"themes/next/source/images/wechat-reward-image.jpg","hash":"380a11acdfa42bdfbd15b08fe088f4926407438c","modified":1515554420000},{"_id":"themes/next/source/images/wechat.png","hash":"826ebf5e64a5bbf8bc27097fda148609075cd9bb","modified":1515554420000},{"_id":"themes/next/layout/_scripts/schemes/mist.swig","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/layout/_scripts/schemes/muse.swig","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/source/css/_mixins/Mist.styl","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/source/css/_mixins/Muse.styl","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/source/css/_mixins/custom.styl","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/source/css/_variables/Muse.styl","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/source/css/_variables/custom.styl","hash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","modified":1515554420000},{"_id":"themes/next/layout/_scripts/pages/post-details.swig","hash":"069d1357c717572256e5cdee09574ebce529cbae","modified":1515554419000},{"_id":"themes/next/layout/_scripts/schemes/pisces.swig","hash":"a44acf9b0d0f44ef3dfc767376a95c984cc127de","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/analytics.swig","hash":"0a89c04055bade7baa5962f1d5aefe438d83a244","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/comments.swig","hash":"907b931d775d32405d02a25b3b0a3ac03bf804d0","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/localsearch.swig","hash":"7f7148c8f52e4d3cfc070d964160362179fa8e91","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/lean-analytics.swig","hash":"92dc60821307fc9769bea9b2d60adaeb798342af","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/mathjax.swig","hash":"5bafc33f57508d1d04a9930165240f6e9efa8d6d","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/tinysou.swig","hash":"cb3a5d36dbe1630bab84e03a52733a46df7c219b","modified":1515554420000},{"_id":"themes/next/layout/_partials/head/external-fonts.swig","hash":"7ce76358411184482bb0934e70037949dd0da8ca","modified":1515554419000},{"_id":"themes/next/layout/_partials/search/localsearch.swig","hash":"ff5523d5dacaa77a55a24e50e6e6530c3b98bfad","modified":1515554419000},{"_id":"themes/next/layout/_partials/search/swiftype.swig","hash":"959b7e04a96a5596056e4009b73b6489c117597e","modified":1515554419000},{"_id":"themes/next/layout/_partials/search/tinysou.swig","hash":"eefe2388ff3d424694045eda21346989b123977c","modified":1515554419000},{"_id":"themes/next/layout/_partials/share/add-this.swig","hash":"c07f7b2f264e5215b8ed42d67e8cef2477558364","modified":1515554419000},{"_id":"themes/next/layout/_partials/share/baidushare.swig","hash":"7ca5cb4daa58b3504e17f3e02975e794bc634658","modified":1515554419000},{"_id":"themes/next/layout/_partials/share/duoshuo_share.swig","hash":"89c5a5240ecb223acfe1d12377df5562a943fd5d","modified":1515554419000},{"_id":"themes/next/layout/_partials/share/jiathis.swig","hash":"a8f642679d53d053cb95e7f71ffdbb30f7de5b66","modified":1515554419000},{"_id":"themes/next/source/css/_custom/custom.styl","hash":"ca806cc3bff5aaadb3815835ea227c4eb7d1af29","modified":1515554420000},{"_id":"themes/next/source/css/_mixins/Pisces.styl","hash":"715d5b40dc52f319fe4bff0325beb874774d9bd9","modified":1515554420000},{"_id":"themes/next/source/css/_mixins/base.styl","hash":"78a83c38f69a8747bb74e420e6c9eeef1ea76525","modified":1515554420000},{"_id":"themes/next/source/css/_variables/Mist.styl","hash":"c8d35a6b9e3bff6d8fdb66de853065af9d37562d","modified":1515554420000},{"_id":"themes/next/source/css/_variables/Pisces.styl","hash":"3ead77befa064d6327dc7afd0a5af7be59a5f196","modified":1515554420000},{"_id":"themes/next/source/css/_variables/base.styl","hash":"17624186f7a1f28daddea258d044f8e03b2f4bea","modified":1515554420000},{"_id":"themes/next/source/js/src/affix.js","hash":"978e0422b5bf1b560236d8d10ebc1adcf66392e3","modified":1515554420000},{"_id":"themes/next/source/js/src/bootstrap.js","hash":"39bf93769d9080fa01a9a875183b43198f79bc19","modified":1515554420000},{"_id":"themes/next/source/js/src/hook-duoshuo.js","hash":"a6119070c0119f33e08b29da7d2cce2635eb40a0","modified":1515554420000},{"_id":"themes/next/source/js/src/motion.js","hash":"269414e84df544a4ccb88519f6abae4943db3c67","modified":1515554420000},{"_id":"themes/next/source/js/src/post-details.js","hash":"2038f54e289b6da5def09689e69f623187147be5","modified":1515554420000},{"_id":"themes/next/source/js/src/scrollspy.js","hash":"fe4da1b9fe73518226446f5f27d2831e4426fc35","modified":1515554420000},{"_id":"themes/next/source/js/src/utils.js","hash":"e5cb720894c4bc28ca8f10b33df127fb394018d9","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery/.bower.json","hash":"91745c2cc6c946c7275f952b2b0760b880cea69e","modified":1515554420000},{"_id":"themes/next/source/vendors/fastclick/.bower.json","hash":"93ebd5b35e632f714dcf1753e1f6db77ec74449b","modified":1515554420000},{"_id":"themes/next/source/vendors/fastclick/LICENSE","hash":"dcd5b6b43095d9e90353a28b09cb269de8d4838e","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/.gitignore","hash":"69d152fa46b517141ec3b1114dd6134724494d83","modified":1515554420000},{"_id":"themes/next/source/vendors/fastclick/README.md","hash":"1decd8e1adad2cd6db0ab50cf56de6035156f4ea","modified":1515554420000},{"_id":"themes/next/source/vendors/fastclick/bower.json","hash":"13379463c7463b4b96d13556b46faa4cc38d81e6","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/.bower.json","hash":"7da985a99674e54f514d4fd9fcd3bcea6e7e41d5","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/.npmignore","hash":"dcf470ab3a358103bb896a539cc03caeda10fa8b","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/HELP-US-OUT.txt","hash":"69a4c537d167b68a0ccf1c6febd138aeffca60d6","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/bower.json","hash":"279a8a718ab6c930a67c41237f0aac166c1b9440","modified":1515554420000},{"_id":"themes/next/source/vendors/velocity/.bower.json","hash":"05f960846f1c7a93dab1d3f9a1121e86812e8c88","modified":1515554420000},{"_id":"themes/next/source/vendors/velocity/bower.json","hash":"2ec99573e84c7117368beccb9e94b6bf35d2db03","modified":1515554420000},{"_id":"themes/next/source/vendors/velocity/velocity.min.js","hash":"2f1afadc12e4cf59ef3b405308d21baa97e739c6","modified":1515554420000},{"_id":"themes/next/source/vendors/velocity/velocity.ui.js","hash":"6a1d101eab3de87527bb54fcc8c7b36b79d8f0df","modified":1515554420000},{"_id":"themes/next/source/vendors/velocity/velocity.ui.min.js","hash":"ed5e534cd680a25d8d14429af824f38a2c7d9908","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery_lazyload/.bower.json","hash":"b7638afc93e9cd350d0783565ee9a7da6805ad8e","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery_lazyload/CONTRIBUTING.md","hash":"4891864c24c28efecd81a6a8d3f261145190f901","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery_lazyload/README.md","hash":"895d50fa29759af7835256522e9dd7dac597765c","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery_lazyload/bower.json","hash":"65bc85d12197e71c40a55c0cd7f6823995a05222","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery_lazyload/jquery.scrollstop.js","hash":"0e9a81785a011c98be5ea821a8ed7d411818cfd1","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery_lazyload/jquery.lazyload.js","hash":"481fd478650e12b67c201a0ea41e92743f8b45a3","modified":1515554420000},{"_id":"themes/next/source/vendors/jquery/index.js","hash":"41b4bfbaa96be6d1440db6e78004ade1c134e276","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/analytics/baidu-analytics.swig","hash":"7c43d66da93cde65b473a7d6db2a86f9a42647d6","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/analytics/busuanzi-counter.swig","hash":"4fcbf57c4918528ab51d3d042cff92cf5aefb599","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/analytics/cnzz-analytics.swig","hash":"1e3e1c6231408e18e8485a8e0e59e8880349b210","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/analytics/facebook-sdk.swig","hash":"394d008e5e94575280407ad8a1607a028026cbc3","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/analytics/google-analytics.swig","hash":"30a23fa7e816496fdec0e932aa42e2d13098a9c2","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/analytics/tencent-analytics.swig","hash":"3658414379e0e8a34c45c40feadc3edc8dc55f88","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/comments/disqus.swig","hash":"bff3b18f56175c53f3bc6d733166c4d998e08732","modified":1515554420000},{"_id":"themes/next/layout/_scripts/third-party/comments/duoshuo.swig","hash":"696666141cdd204fd8818ac2ad18f05e320f8587","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/buttons.styl","hash":"0dfb4b3ba3180d7285e66f270e1d3fa0f132c3d2","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/comments.styl","hash":"471f1627891aca5c0e1973e09fbcb01e1510d193","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/components.styl","hash":"10994990d6e0b4d965a728a22cf7f6ee29cae9f6","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/back-to-top.styl","hash":"b49efc66bd055a2d0be7deabfcb02ee72a9a28c8","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/pagination.styl","hash":"711c8830886619d4f4a0598b0cde5499dce50c62","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/tag-cloud.styl","hash":"dd8a3b22fc2f222ac6e6c05bd8a773fb039169c0","modified":1515554420000},{"_id":"themes/next/source/css/_common/scaffolding/base.styl","hash":"5304f99581da3a31de3ecec959b7adf9002fde83","modified":1515554420000},{"_id":"themes/next/source/css/_common/outline/outline.styl","hash":"2186be20e317505cd31886f1291429cc21f76703","modified":1515554420000},{"_id":"themes/next/source/css/_common/scaffolding/helpers.styl","hash":"54c90cf7bdbf5c596179d8dae6e671bad1292662","modified":1515554420000},{"_id":"themes/next/source/css/_common/scaffolding/normalize.styl","hash":"ece571f38180febaf02ace8187ead8318a300ea7","modified":1515554420000},{"_id":"themes/next/source/css/_common/scaffolding/scaffolding.styl","hash":"013619c472c7e4b08311c464fcbe9fcf5edde603","modified":1515554420000},{"_id":"themes/next/source/css/_common/scaffolding/tables.styl","hash":"64f5d56c08d74a338813df1265580ca0cbf0190b","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/_header.styl","hash":"5ae7906dc7c1d9468c7f4b4a6feddddc555797a1","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/_logo.styl","hash":"38e5df90c8689a71c978fd83ba74af3d4e4e5386","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/_menu.styl","hash":"b0dcca862cd0cc6e732e33d975b476d744911742","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/_posts-expanded.styl","hash":"4303776991ef28f5742ca51c7dffe6f12f0acf34","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/_search.styl","hash":"1452cbe674cc1d008e1e9640eb4283841058fc64","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/index.styl","hash":"9a5581a770af8964064fef7afd3e16963e45547f","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/_base.styl","hash":"c2d079788d6fc2e9a191ccdae94e50d55bf849dc","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Muse/_logo.styl","hash":"8829bc556ca38bfec4add4f15a2f028092ac6d46","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Muse/_menu.styl","hash":"c2c6c4f6434b4f94aac2af5861cd769427f0ee10","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Muse/_layout.styl","hash":"6ed60cc621bac096c0ed7534fa25b1a52dc571d4","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Muse/_search.styl","hash":"1452cbe674cc1d008e1e9640eb4283841058fc64","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Muse/index.styl","hash":"a0e2030a606c934fb2c5c7373aaae04a1caac4c5","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Pisces/_brand.styl","hash":"be22ad34f546a07f6d56b424338cdd898683eea4","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Pisces/_full-image.styl","hash":"938d39eedc6e3d33918c1145a5bf1e79991d3fcf","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Pisces/_layout.styl","hash":"8d7cecde4933900c7df2db9d0a98f5f82f88dc93","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Pisces/_menu.styl","hash":"d09280e5b79f3b573edb30f30c7a5f03ac640986","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Pisces/_posts.styl","hash":"2f878213cb24c5ddc18877f6d15ec5c5f57745ac","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Pisces/_sidebar.styl","hash":"d4b7bd610ca03dbb2f5b66631c0e84a79fb4660b","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Pisces/index.styl","hash":"1b10ba2d3ad0c063c418dc94a0b7e0db4b342c53","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/blank.gif","hash":"2daeaa8b5f19f0bc209d976c02bd6acb51b00b0a","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/fancybox_loading.gif","hash":"1a755fb2599f3a313cc6cfdb14df043f8c14a99c","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/[email protected]","hash":"273b123496a42ba45c3416adb027cd99745058b0","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/fancybox_overlay.png","hash":"b3a4ee645ba494f52840ef8412015ba0f465dbe0","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/fancybox_sprite.png","hash":"17df19f97628e77be09c352bf27425faea248251","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/[email protected]","hash":"30c58913f327e28f466a00f4c1ac8001b560aed8","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/jquery.fancybox.css","hash":"5f163444617b6cf267342f06ac166a237bb62df9","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/jquery.fancybox.js","hash":"1cf3d47b5ccb7cb6e9019c64f2a88d03a64853e4","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/jquery.fancybox.pack.js","hash":"53360764b429c212f424399384417ccc233bb3be","modified":1515554420000},{"_id":"themes/next/source/js/src/schemes/pisces.js","hash":"7506e7490c69a200831393c38d25e91c156bd471","modified":1515554420000},{"_id":"themes/next/source/vendors/fastclick/lib/fastclick.js","hash":"06cef196733a710e77ad7e386ced6963f092dc55","modified":1515554420000},{"_id":"themes/next/source/vendors/fastclick/lib/fastclick.min.js","hash":"2cae0f5a6c5d6f3cb993015e6863f9483fc4de18","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.woff2","hash":"574ea2698c03ae9477db2ea3baf460ee32f1a7ea","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/css/font-awesome.min.css","hash":"05ea25bc9b3ac48993e1fee322d3bc94b49a6e22","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/css/font-awesome.css","hash":"3b87c2560832748cd06f9bfd2fd6ea8edbdae8c7","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/css/font-awesome.css.map","hash":"0189d278706509412bac4745f96c83984e1d59f4","modified":1515554420000},{"_id":"themes/next/source/vendors/ua-parser-js/dist/ua-parser.min.js","hash":"38628e75e4412cc6f11074e03e1c6d257aae495b","modified":1515554420000},{"_id":"themes/next/source/vendors/ua-parser-js/dist/ua-parser.pack.js","hash":"214dad442a92d36af77ed0ca1d9092b16687f02f","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/fonts/FontAwesome.otf","hash":"0112e96f327d413938d37c1693806f468ffdbace","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.eot","hash":"b3c2f08e73320135b69c23a3908b87a12053a2f6","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.woff","hash":"507970402e328b2baeb05bde73bf9ded4e2c3a2d","modified":1515554420000},{"_id":"themes/next/source/vendors/velocity/velocity.js","hash":"9f08181baea0cc0e906703b7e5df9111b9ef3373","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/header/header.styl","hash":"ae1ca14e51de67b07dba8f61ec79ee0e2e344574","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/footer/footer.styl","hash":"8994ffcce84deac0471532f270f97c44fea54dc0","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/header/headerband.styl","hash":"d27448f199fc2f9980b601bc22b87f08b5d64dd1","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/header/menu.styl","hash":"c890ce7fe933abad7baf39764a01894924854e92","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/header/site-meta.styl","hash":"6c00f6e0978f4d8f9a846a15579963728aaa6a17","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/header/site-nav.styl","hash":"49c2b2c14a1e7fcc810c6be4b632975d0204c281","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/highlight/highlight.styl","hash":"4da051c7f3924fa2db1e73c55b2baf1c2c150255","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/highlight/theme.styl","hash":"90f8f9706cd7fe829cf06e9959a65fd3f8b994fa","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/pages/archive.styl","hash":"7778920dd105fa4de3a7ab206eeba30b1a7bac45","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/pages/categories.styl","hash":"4eff5b252d7b614e500fc7d52c97ce325e57d3ab","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/pages/pages.styl","hash":"3c46efd6601e268093ce6d7b1471d18501878f0d","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/pages/post-detail.styl","hash":"9bf4362a4d0ae151ada84b219d39fbe5bb8c790e","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-collapse.styl","hash":"8fae54591877a73dff0b29b2be2e8935e3c63575","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-eof.styl","hash":"2cdc094ecf907a02fce25ad4a607cd5c40da0f2b","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-expand.styl","hash":"b25132fe6a7ad67059a2c3afc60feabb479bdd75","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-gallery.styl","hash":"387ce23bba52b22a586b2dfb4ec618fe1ffd3926","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-meta.styl","hash":"d543d1377c1f61b70e3adb6da0eb12797552e5f2","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-more-link.styl","hash":"15063d79b5befc21820baf05d6f20cc1c1787477","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-nav.styl","hash":"cbca4842a54950e2934b3b8f3cd940f122111aef","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-reward.styl","hash":"e792c8dc41561c96d128e9b421187f1c3dc978a0","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-tags.styl","hash":"a352ae5b1f8857393bf770d2e638bf15f0c9585d","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-title.styl","hash":"963105a531403d7aad6d9e5e23e3bfabb8ec065a","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post.styl","hash":"4eb18b12fa0ea6c35925d9a64f64e2a7dae8c7fd","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/post/post-type.styl","hash":"10251257aceecb117233c9554dcf8ecfef8e2104","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar-author-links.styl","hash":"2e7ec9aaa3293941106b1bdd09055246aa3c3dc6","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar-author.styl","hash":"920343e41c124221a17f050bbb989494d44f7a24","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar-blogroll.styl","hash":"c44f6a553ec7ea5508f2054a13be33a62a15d3a9","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar-feed-link.styl","hash":"9486ddd2cb255227db102d09a7df4cae0fabad72","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar-nav.styl","hash":"45fa7193435a8eae9960267438750b4c9fa9587f","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar-toggle.styl","hash":"2d3abbc85b979a648e0e579e45f16a6eba49d1e7","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar-toc.styl","hash":"7690b9596ec3a49befbe529a5a2649abec0faf76","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/sidebar.styl","hash":"234facd038f144bd0fe09a31ed1357c5d74c517f","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/sidebar/site-state.styl","hash":"3623e7fa4324ec1307370f33d8f287a9e20a5578","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/tags/blockquote-center.styl","hash":"c2abe4d87148e23e15d49ee225bc650de60baf46","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/tags/full-image.styl","hash":"618f73450cf541f88a4fddc3d22898aee49d105d","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/tags/group-pictures.styl","hash":"4851b981020c5cbc354a1af9b831a2dcb3cf9d39","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/tags/tags.styl","hash":"8e66c2635d48e11de616bb29c4b1323698eebc0a","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/third-party/baidushare.styl","hash":"93b08815c4d17e2b96fef8530ec1f1064dede6ef","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/third-party/busuanzi-counter.styl","hash":"b03f891883446f3a5548b7cc90d29c77e62f1053","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/third-party/duoshuo.styl","hash":"2340dd9b3202c61d73cc708b790fac5adddbfc7f","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/third-party/jiathis.styl","hash":"327b5f63d55ec26f7663185c1a778440588d9803","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/third-party/third-party.styl","hash":"3afc459442c132c480d1d832f1a872f1070bb048","modified":1515554420000},{"_id":"themes/next/source/css/_common/components/third-party/localsearch.styl","hash":"795d94561888d31cb7a6ff4a125596809ea69b7d","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/outline/outline.styl","hash":"5dc4859c66305f871e56cba78f64bfe3bf1b5f01","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Mist/sidebar/sidebar-blogroll.styl","hash":"8b8e8cbce98a9296c8fd77f512ae85d945f65d40","modified":1515554420000},{"_id":"themes/next/source/css/_schemes/Muse/sidebar/sidebar-blogroll.styl","hash":"8b8e8cbce98a9296c8fd77f512ae85d945f65d40","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/helpers/fancybox_buttons.png","hash":"e385b139516c6813dcd64b8fc431c364ceafe5f3","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-buttons.css","hash":"1a9d8e5c22b371fcc69d4dbbb823d9c39f04c0c8","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-buttons.js","hash":"91e41741c2e93f732c82aaacec4cfc6e3f3ec876","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-media.js","hash":"3bdf69ed2469e4fb57f5a95f17300eef891ff90d","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-thumbs.css","hash":"4ac329c16a5277592fc12a37cca3d72ca4ec292f","modified":1515554420000},{"_id":"themes/next/source/vendors/fancybox/source/helpers/jquery.fancybox-thumbs.js","hash":"53e194f4a72e649c04fb586dd57762b8c022800b","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.ttf","hash":"27cf1f2ec59aece6938c7bb2feb0e287ea778ff9","modified":1515554420000},{"_id":"themes/next/source/vendors/font-awesome/fonts/fontawesome-webfont.svg","hash":"2b3c8ba7008cc014d8fb37abc6f9f49aeda83824","modified":1515554420000},{"_id":"public/about/index.html","hash":"cb00f569898392d74360e92d3d9e2ae005e3d038","modified":1515565039495},{"_id":"public/categories/index.html","hash":"9a46f44e1cca25dec6ef74235700b8b7c255e162","modified":1515565039496},{"_id":"public/tags/index.html","hash":"040e393e4d351dc98fc8dbc639c4df7819a911f7","modified":1515565039496},{"_id":"public/categories/编程/index.html","hash":"b01720036a30668c42ce4ec7722ed7aadef04434","modified":1515565039496},{"_id":"public/categories/编程/page/2/index.html","hash":"89b98ec9ae9f2fe9dee033495e2c651878f09d3f","modified":1515565039496},{"_id":"public/categories/编程/page/3/index.html","hash":"4c78a9a3fff1b417605584a4a4433b1aaee6c2e8","modified":1515565039496},{"_id":"public/categories/hexo/index.html","hash":"5d3b080f902f27ef3fc5104dc6556936024eb5ed","modified":1515565039496},{"_id":"public/categories/数据库/index.html","hash":"e8a74bac971486192c089e9bed48d36d0b6244a5","modified":1515565039496},{"_id":"public/categories/感想/index.html","hash":"4abd214cfafbb4346bd3ce7f66ab9f2f8745f4cf","modified":1515565039496},{"_id":"public/archives/index.html","hash":"30e33fcc8c5fd7905bad0cf2ddcafb0ed3bca7f6","modified":1515565039496},{"_id":"public/archives/page/2/index.html","hash":"b29ef15877b5350d717a41fb9f8bb2710fab5319","modified":1515565039496},{"_id":"public/archives/page/3/index.html","hash":"7866b210f96cc8a7c6d5bb3f86b9851c07e361ca","modified":1515565039496},{"_id":"public/archives/page/4/index.html","hash":"1c651d35550b3e85901c00fe4712557e9499bc11","modified":1515565039497},{"_id":"public/archives/2016/index.html","hash":"13cfc75827454c15e57261b69e6cf7d132a78240","modified":1515565039497},{"_id":"public/archives/2016/page/2/index.html","hash":"fb9d01259e6b317591700dee2852acfff9d6fe46","modified":1515565039497},{"_id":"public/archives/2016/page/3/index.html","hash":"0f24715a5eadc76645b5c9cd7bc449bf268b0d92","modified":1515565039497},{"_id":"public/archives/2016/page/4/index.html","hash":"658edf3e2648b101d3cb3e4adacd0abf92f8d4c5","modified":1515565039497},{"_id":"public/archives/2016/07/index.html","hash":"badad2de6fc4b6988d9ca11733b6105795140b53","modified":1515565039497},{"_id":"public/archives/2016/08/index.html","hash":"8dd6f37e6e9ba40613935feeac390925ea7032d7","modified":1515565039497},{"_id":"public/archives/2016/08/page/2/index.html","hash":"642e885e7946afd62e589d01d831a8c5ff361cdd","modified":1515565039497},{"_id":"public/archives/2016/09/index.html","hash":"6bf3c749f456890003065aac115b3aefce27dd8b","modified":1515565039497},{"_id":"public/archives/2017/index.html","hash":"0fbad70030489e5f62abb7355462e77155280843","modified":1515565039497},{"_id":"public/archives/2017/06/index.html","hash":"3917dc1f41ce04a02b4635eccae4d57153acdea3","modified":1515565039497},{"_id":"public/archives/2018/index.html","hash":"089035f4d1b44049fed92762c5a5e03d1c303316","modified":1515565039497},{"_id":"public/archives/2018/01/index.html","hash":"e5a7928eabff77ce1b791d984e81098a20234cd6","modified":1515565039497},{"_id":"public/tags/Java/index.html","hash":"c8ca013ea343c3eb243deafe125b123d75c4779d","modified":1515565039497},{"_id":"public/tags/Java/page/2/index.html","hash":"fa930558a7f8409a8af33eb73dcf287e7bf36c72","modified":1515565039497},{"_id":"public/tags/Java/page/3/index.html","hash":"995f75144e665f5722dd75f75bfd35c8295be7f4","modified":1515565039498},{"_id":"public/tags/博客之路/index.html","hash":"da72aa65d19c87266d4cbfb51bb28060b652526e","modified":1515565039498},{"_id":"public/tags/HEXO/index.html","hash":"d02f950ada90c45f6091d7ff52a6dbe269d96466","modified":1515565039498},{"_id":"public/tags/SQL/index.html","hash":"d8223735c90daa066275055d66de715696c1d059","modified":1515565039498},{"_id":"public/tags/生活,感想/index.html","hash":"81bee62f55097d1876640c49bee32c01e97086f4","modified":1515565039498},{"_id":"public/tags/Exception/index.html","hash":"5b0fcfebffa44cb4d2ab70a88fca8fe16fd9e45a","modified":1515565039498},{"_id":"public/2018/01/10/Spring Boot运行原理/index.html","hash":"d9ef041824f7cbdf761213fbfca29ed85f35ae13","modified":1515565039498},{"_id":"public/2017/06/20/Java中的字符串和表达式/index.html","hash":"4b11bd5b49a94642972a6867f077459a403032ae","modified":1515565039498},{"_id":"public/2017/06/15/解析json对象/index.html","hash":"498ea3c58089c7e9b8647ed31aec7ae60b96c804","modified":1515565039498},{"_id":"public/2016/09/25/SQL连接查询语法/index.html","hash":"266f02015a9dc21ea528128a15d8b554bdcf261e","modified":1515565039498},{"_id":"public/2016/09/03/SQL子查询/index.html","hash":"099f6e3400ffbd1c6eba7612eb6fe6726dc0aee7","modified":1515565039498},{"_id":"public/2016/09/03/SQL分组查询/index.html","hash":"6fdb9d6adcd122011a308946b8a77584c74d872d","modified":1515565039498},{"_id":"public/2016/09/01/JavaWeb开发掌握的技能/index.html","hash":"8bc531e0aa7124ad6a40877ea0b3c7966b91ab6d","modified":1515565039498},{"_id":"public/2016/08/23/条件查询和分页原理到底是怎么样的(二)/index.html","hash":"443fc873394e695efd71a0593edc338d6d1bb24d","modified":1515565039498},{"_id":"public/2016/08/22/条件查询和分页原理到底是怎么样的/index.html","hash":"1612ca1850f7ee5d41b9c3b71230c07b5fe77537","modified":1515565039498},{"_id":"public/2016/08/20/hello-world/index.html","hash":"5c1a8a58c8525739755650f82b949017b8a62c3e","modified":1515565039498},{"_id":"public/2016/08/11/简单实例之文件下载(二)/index.html","hash":"62f2efff91d50bd0af8b9040e7120a24e62d0459","modified":1515565039498},{"_id":"public/2016/08/11/简单实例之文件下载/index.html","hash":"ace821c4ba14773c59b7357c7502101e49986010","modified":1515565039498},{"_id":"public/2016/08/11/文件上传/index.html","hash":"fcf5dae792475673dd448cb620bbdd74fc8a2217","modified":1515565039499},{"_id":"public/2016/08/10/文件上传(一)/index.html","hash":"4738027fc8ede7cdf349d70fb03815a9bce91e25","modified":1515565039499},{"_id":"public/2016/08/05/SSH2三大框架的整合/index.html","hash":"762517a92ec4f3794d6f001d16aa83a0708bc90b","modified":1515565039499},{"_id":"public/2016/08/02/关于java-io-WriteAbortedException/index.html","hash":"679bda43857f01de6f672c9f584c37601862a70d","modified":1515565039499},{"_id":"public/2016/07/28/java经典程序设计/index.html","hash":"25670c9626c86f56e124b1caf78b0cfb960f91b8","modified":1515565039499},{"_id":"public/2016/07/25/Github上搭建个人博客/index.html","hash":"fa06db82b476c4bfc3050cb057022171812ae28a","modified":1515565039499},{"_id":"public/2016/07/21/回首向来萧瑟萧瑟处,也无风雨也无晴——新的开始/index.html","hash":"f96d371dc8758f3e0609b422038213f5ab78dc81","modified":1515565039499},{"_id":"public/index.html","hash":"a54116f7d0b02bf5771a32789624b125a6033d73","modified":1515565039499},{"_id":"public/page/2/index.html","hash":"8e25527b4bac80f99e07a6d51508e32b1d09dc08","modified":1515565039499},{"_id":"public/page/3/index.html","hash":"a7155232a709cfcbd1cf4faf7c99c6e76a27e3ca","modified":1515565039499},{"_id":"public/page/4/index.html","hash":"674fe1338c0270111d932f584e4270d725016b4a","modified":1515565039499},{"_id":"public/favicon.ico","hash":"b4350b48a09a4b87f87138389ab9b12ee7fa0b8e","modified":1515565039507},{"_id":"public/images/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67.png","hash":"c00a90ad148620a49f0939fea2d55094047bce29","modified":1515565039508},{"_id":"public/images/avatar.gif","hash":"264082bb3a1af70d5499c7d22b0902cb454b6d12","modified":1515565039508},{"_id":"public/images/avatar.png","hash":"1bfdcfd509383a0324a45ae130981bf97f88ac99","modified":1515565039508},{"_id":"public/images/cc-by-nc-nd.svg","hash":"c6524ece3f8039a5f612feaf865d21ec8a794564","modified":1515565039508},{"_id":"public/images/cc-by-nc-sa.svg","hash":"3031be41e8753c70508aa88e84ed8f4f653f157e","modified":1515565039508},{"_id":"public/images/cc-by-nc.svg","hash":"8d39b39d88f8501c0d27f8df9aae47136ebc59b7","modified":1515565039508},{"_id":"public/images/cc-by-sa.svg","hash":"aa4742d733c8af8d38d4c183b8adbdcab045872e","modified":1515565039508},{"_id":"public/images/cc-by-nd.svg","hash":"c563508ce9ced1e66948024ba1153400ac0e0621","modified":1515565039508},{"_id":"public/images/cc-by.svg","hash":"28a0a4fe355a974a5e42f68031652b76798d4f7e","modified":1515565039508},{"_id":"public/images/forkme_left_green_007200.png","hash":"c00a90ad148620a49f0939fea2d55094047bce29","modified":1515565039508},{"_id":"public/images/cc-zero.svg","hash":"87669bf8ac268a91d027a0a4802c92a1473e9030","modified":1515565039508},{"_id":"public/images/loading.gif","hash":"5fbd472222feb8a22cf5b8aa5dc5b8e13af88e2b","modified":1515565039508},{"_id":"public/images/placeholder.gif","hash":"5fbd472222feb8a22cf5b8aa5dc5b8e13af88e2b","modified":1515565039508},{"_id":"public/images/quote-l.svg","hash":"94e870b4c8c48da61d09522196d4dd40e277a98f","modified":1515565039508},{"_id":"public/images/quote-r.svg","hash":"e60ae504f9d99b712c793c3740c6b100d057d4ec","modified":1515565039508},{"_id":"public/images/searchicon.png","hash":"67727a6a969be0b2659b908518fa6706eed307b8","modified":1515565039508},{"_id":"public/vendors/fastclick/LICENSE","hash":"dcd5b6b43095d9e90353a28b09cb269de8d4838e","modified":1515565039508},{"_id":"public/vendors/font-awesome/HELP-US-OUT.txt","hash":"69a4c537d167b68a0ccf1c6febd138aeffca60d6","modified":1515565039508},{"_id":"public/vendors/fancybox/source/blank.gif","hash":"2daeaa8b5f19f0bc209d976c02bd6acb51b00b0a","modified":1515565039508},{"_id":"public/vendors/fancybox/source/fancybox_loading.gif","hash":"1a755fb2599f3a313cc6cfdb14df043f8c14a99c","modified":1515565039509},{"_id":"public/vendors/fancybox/source/[email protected]","hash":"273b123496a42ba45c3416adb027cd99745058b0","modified":1515565039509},{"_id":"public/images/wechat-qcode.jpg","hash":"d2f738048eb32f36de8febdbfdd69b7c7522a707","modified":1515565039509},{"_id":"public/vendors/fancybox/source/fancybox_overlay.png","hash":"b3a4ee645ba494f52840ef8412015ba0f465dbe0","modified":1515565039509},{"_id":"public/images/wechat-reward-image.jpg","hash":"380a11acdfa42bdfbd15b08fe088f4926407438c","modified":1515565039509},{"_id":"public/images/wechat.png","hash":"826ebf5e64a5bbf8bc27097fda148609075cd9bb","modified":1515565039509},{"_id":"public/vendors/fancybox/source/fancybox_sprite.png","hash":"17df19f97628e77be09c352bf27425faea248251","modified":1515565039509},{"_id":"public/vendors/fancybox/source/[email protected]","hash":"30c58913f327e28f466a00f4c1ac8001b560aed8","modified":1515565039509},{"_id":"public/vendors/font-awesome/fonts/fontawesome-webfont.woff2","hash":"574ea2698c03ae9477db2ea3baf460ee32f1a7ea","modified":1515565039510},{"_id":"public/vendors/font-awesome/css/font-awesome.css.map","hash":"0189d278706509412bac4745f96c83984e1d59f4","modified":1515565039510},{"_id":"public/vendors/fancybox/source/helpers/fancybox_buttons.png","hash":"e385b139516c6813dcd64b8fc431c364ceafe5f3","modified":1515565039510},{"_id":"public/assets/js/APlayer.min.js","hash":"3d85f0089e50226467642c1ecadd1aa7b2a47972","modified":1515565039510},{"_id":"public/vendors/font-awesome/fonts/FontAwesome.otf","hash":"0112e96f327d413938d37c1693806f468ffdbace","modified":1515565040381},{"_id":"public/vendors/font-awesome/fonts/fontawesome-webfont.eot","hash":"b3c2f08e73320135b69c23a3908b87a12053a2f6","modified":1515565040384},{"_id":"public/vendors/font-awesome/fonts/fontawesome-webfont.woff","hash":"507970402e328b2baeb05bde73bf9ded4e2c3a2d","modified":1515565040386},{"_id":"public/404.html","hash":"a361af57cdda47f8218e907af49b0749b396775e","modified":1515565040392},{"_id":"public/js/src/affix.js","hash":"978e0422b5bf1b560236d8d10ebc1adcf66392e3","modified":1515565040392},{"_id":"public/js/src/bootstrap.js","hash":"39bf93769d9080fa01a9a875183b43198f79bc19","modified":1515565040392},{"_id":"public/js/src/hook-duoshuo.js","hash":"a6119070c0119f33e08b29da7d2cce2635eb40a0","modified":1515565040392},{"_id":"public/js/src/motion.js","hash":"269414e84df544a4ccb88519f6abae4943db3c67","modified":1515565040392},{"_id":"public/js/src/post-details.js","hash":"2038f54e289b6da5def09689e69f623187147be5","modified":1515565040392},{"_id":"public/js/src/scrollspy.js","hash":"fe4da1b9fe73518226446f5f27d2831e4426fc35","modified":1515565040392},{"_id":"public/js/src/utils.js","hash":"e5cb720894c4bc28ca8f10b33df127fb394018d9","modified":1515565040392},{"_id":"public/vendors/fastclick/README.html","hash":"da3c74d484c73cc7df565e8abbfa4d6a5a18d4da","modified":1515565040392},{"_id":"public/vendors/fastclick/bower.json","hash":"4dcecf83afddba148464d5339c93f6d0aa9f42e9","modified":1515565040393},{"_id":"public/vendors/font-awesome/bower.json","hash":"64394a2a9aa00f8e321d8daa5e51a420f0e96dad","modified":1515565040393},{"_id":"public/vendors/velocity/bower.json","hash":"0ef14e7ccdfba5db6eb3f8fc6aa3b47282c36409","modified":1515565040393},{"_id":"public/vendors/velocity/velocity.ui.min.js","hash":"ed5e534cd680a25d8d14429af824f38a2c7d9908","modified":1515565040393},{"_id":"public/vendors/jquery_lazyload/CONTRIBUTING.html","hash":"a6358170d346af13b1452ac157b60505bec7015c","modified":1515565040393},{"_id":"public/vendors/jquery_lazyload/README.html","hash":"bde24335f6bc09d8801c0dcd7274f71b466552bd","modified":1515565040393},{"_id":"public/vendors/jquery_lazyload/bower.json","hash":"ae3c3b61e6e7f9e1d7e3585ad854380ecc04cf53","modified":1515565040393},{"_id":"public/vendors/jquery_lazyload/jquery.scrollstop.js","hash":"0e9a81785a011c98be5ea821a8ed7d411818cfd1","modified":1515565040393},{"_id":"public/vendors/jquery_lazyload/jquery.lazyload.js","hash":"481fd478650e12b67c201a0ea41e92743f8b45a3","modified":1515565040393},{"_id":"public/vendors/fancybox/source/jquery.fancybox.css","hash":"5f163444617b6cf267342f06ac166a237bb62df9","modified":1515565040393},{"_id":"public/js/src/schemes/pisces.js","hash":"7506e7490c69a200831393c38d25e91c156bd471","modified":1515565040393},{"_id":"public/vendors/fastclick/lib/fastclick.min.js","hash":"2cae0f5a6c5d6f3cb993015e6863f9483fc4de18","modified":1515565040393},{"_id":"public/vendors/ua-parser-js/dist/ua-parser.min.js","hash":"38628e75e4412cc6f11074e03e1c6d257aae495b","modified":1515565040393},{"_id":"public/vendors/ua-parser-js/dist/ua-parser.pack.js","hash":"214dad442a92d36af77ed0ca1d9092b16687f02f","modified":1515565040393},{"_id":"public/vendors/fancybox/source/helpers/jquery.fancybox-buttons.css","hash":"1a9d8e5c22b371fcc69d4dbbb823d9c39f04c0c8","modified":1515565040393},{"_id":"public/vendors/fancybox/source/helpers/jquery.fancybox-buttons.js","hash":"91e41741c2e93f732c82aaacec4cfc6e3f3ec876","modified":1515565040394},{"_id":"public/vendors/fancybox/source/helpers/jquery.fancybox-media.js","hash":"3bdf69ed2469e4fb57f5a95f17300eef891ff90d","modified":1515565040394},{"_id":"public/vendors/fancybox/source/helpers/jquery.fancybox-thumbs.css","hash":"4ac329c16a5277592fc12a37cca3d72ca4ec292f","modified":1515565040394},{"_id":"public/vendors/fancybox/source/helpers/jquery.fancybox-thumbs.js","hash":"53e194f4a72e649c04fb586dd57762b8c022800b","modified":1515565040394},{"_id":"public/css/main.css","hash":"cd46b562bcdd034a0bc25998627cd762b8ad077e","modified":1515565040394},{"_id":"public/vendors/velocity/velocity.min.js","hash":"2f1afadc12e4cf59ef3b405308d21baa97e739c6","modified":1515565040394},{"_id":"public/vendors/velocity/velocity.ui.js","hash":"6a1d101eab3de87527bb54fcc8c7b36b79d8f0df","modified":1515565040394},{"_id":"public/vendors/jquery/index.js","hash":"41b4bfbaa96be6d1440db6e78004ade1c134e276","modified":1515565040394},{"_id":"public/vendors/fancybox/source/jquery.fancybox.js","hash":"1cf3d47b5ccb7cb6e9019c64f2a88d03a64853e4","modified":1515565040394},{"_id":"public/vendors/fancybox/source/jquery.fancybox.pack.js","hash":"53360764b429c212f424399384417ccc233bb3be","modified":1515565040394},{"_id":"public/vendors/fastclick/lib/fastclick.js","hash":"06cef196733a710e77ad7e386ced6963f092dc55","modified":1515565040394},{"_id":"public/vendors/font-awesome/css/font-awesome.min.css","hash":"05ea25bc9b3ac48993e1fee322d3bc94b49a6e22","modified":1515565040394},{"_id":"public/vendors/font-awesome/css/font-awesome.css","hash":"3b87c2560832748cd06f9bfd2fd6ea8edbdae8c7","modified":1515565040395},{"_id":"public/vendors/velocity/velocity.js","hash":"9f08181baea0cc0e906703b7e5df9111b9ef3373","modified":1515565040395},{"_id":"public/assets/js/DPlayer.min.js","hash":"520e5980336ef45f3415f0e483ea4b42f07e9999","modified":1515565040395},{"_id":"public/vendors/font-awesome/fonts/fontawesome-webfont.ttf","hash":"27cf1f2ec59aece6938c7bb2feb0e287ea778ff9","modified":1515565040395},{"_id":"public/vendors/font-awesome/fonts/fontawesome-webfont.svg","hash":"2b3c8ba7008cc014d8fb37abc6f9f49aeda83824","modified":1515565040417}],"Category":[{"name":"编程","_id":"cjc8oaidq00053sasgv8x4308"},{"name":"hexo","_id":"cjc8oaie0000b3saseatt3hnh"},{"name":"数据库","_id":"cjc8oaieb000l3sas3y9ndgqh"},{"name":"感想","_id":"cjc8oaier001a3sasjgjcplo8"}],"Data":[],"Page":[{"title":"about","date":"2016-07-21T04:16:04.000Z","type":"about","comments":1,"_content":"## about what ?\n>I've been programming since last year and I've loved technology and programming every since.I like to be a geek.Also I like mountain climbing,it's very funny~\n\n## 关于博客名的解释\n\n>因为博主的名字中有个“霖”字,而\"bubble\"是气泡的意思,球状,又像个0,所以就突然取`bubblelin`为博客名,用前面的翻译就是“0”\n\n## 音乐是最放松的放松\n\n>喜欢听音乐,喜欢听jay的歌曲,to enjoy\n\n![Alt text](http://ww3.sinaimg.cn/large/6a3d492dgw1eo14c1qlg3j218g0tktgw.jpg)\n<!-- {% aplayer \"爱情废柴\" \"周杰伦\" \" http://sc1.111ttt.com/2016/1/06/24/199240143042.mp3\" %} -->\n\n## 歌词精选\n\n<div align = center>\n没有你的冬天\n我会一直唱着唱着\n直到你出现\n为你封麦 只唱你爱\nGoodbye Don't Cry 哭个痛快\n曲终人散 你也走散\n我承认我是爱情里的废柴\n你的离开 喊得太快\n我的依赖 还在耍赖\n眼泪打转 转不回来\n你的笑容灿烂\n</div>\n","source":"about/index.md","raw":"---\ntitle: about\ndate: 2016-07-21 12:16:04\ntype: \"about\"\ncomments: true\n---\n## about what ?\n>I've been programming since last year and I've loved technology and programming every since.I like to be a geek.Also I like mountain climbing,it's very funny~\n\n## 关于博客名的解释\n\n>因为博主的名字中有个“霖”字,而\"bubble\"是气泡的意思,球状,又像个0,所以就突然取`bubblelin`为博客名,用前面的翻译就是“0”\n\n## 音乐是最放松的放松\n\n>喜欢听音乐,喜欢听jay的歌曲,to enjoy\n\n![Alt text](http://ww3.sinaimg.cn/large/6a3d492dgw1eo14c1qlg3j218g0tktgw.jpg)\n<!-- {% aplayer \"爱情废柴\" \"周杰伦\" \" http://sc1.111ttt.com/2016/1/06/24/199240143042.mp3\" %} -->\n\n## 歌词精选\n\n<div align = center>\n没有你的冬天\n我会一直唱着唱着\n直到你出现\n为你封麦 只唱你爱\nGoodbye Don't Cry 哭个痛快\n曲终人散 你也走散\n我承认我是爱情里的废柴\n你的离开 喊得太快\n我的依赖 还在耍赖\n眼泪打转 转不回来\n你的笑容灿烂\n</div>\n","updated":"2018-01-10T06:16:41.000Z","path":"about/index.html","layout":"page","_id":"cjc8oaidf00013sasyftuey5x","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h2 id=\"about-what\"><a href=\"#about-what\" class=\"headerlink\" title=\"about what ?\"></a>about what ?</h2><blockquote>\n<p>I’ve been programming since last year and I’ve loved technology and programming every since.I like to be a geek.Also I like mountain climbing,it’s very funny~</p>\n</blockquote>\n<h2 id=\"关于博客名的解释\"><a href=\"#关于博客名的解释\" class=\"headerlink\" title=\"关于博客名的解释\"></a>关于博客名的解释</h2><blockquote>\n<p>因为博主的名字中有个“霖”字,而”bubble”是气泡的意思,球状,又像个0,所以就突然取<code>bubblelin</code>为博客名,用前面的翻译就是“0”</p>\n</blockquote>\n<h2 id=\"音乐是最放松的放松\"><a href=\"#音乐是最放松的放松\" class=\"headerlink\" title=\"音乐是最放松的放松\"></a>音乐是最放松的放松</h2><blockquote>\n<p>喜欢听音乐,喜欢听jay的歌曲,to enjoy</p>\n</blockquote>\n<p><img src=\"http://ww3.sinaimg.cn/large/6a3d492dgw1eo14c1qlg3j218g0tktgw.jpg\" alt=\"Alt text\"><br><!-- <div id=\"aplayer0\" class=\"aplayer\" style=\"margin-bottom: 20px;\"></div><script>var aplayer0 = new APlayer({element: document.getElementById(\"aplayer0\"),narrow: false,autoplay: false,showlrc: 0,music : {title: \"爱情废柴\",author: \"周杰伦\",url: \"http://sc1.111ttt.com/2016/1/06/24/199240143042.mp3\",pic: \"\"}});aplayer0.init();</script> –></p>\n<h2 id=\"歌词精选\"><a href=\"#歌词精选\" class=\"headerlink\" title=\"歌词精选\"></a>歌词精选</h2><div align = center><br>没有你的冬天<br>我会一直唱着唱着<br>直到你出现<br>为你封麦 只唱你爱<br>Goodbye Don’t Cry 哭个痛快<br>曲终人散 你也走散<br>我承认我是爱情里的废柴<br>你的离开 喊得太快<br>我的依赖 还在耍赖<br>眼泪打转 转不回来<br>你的笑容灿烂<br></div>\n--></p>","excerpt":"","more":"<h2 id=\"about-what\"><a href=\"#about-what\" class=\"headerlink\" title=\"about what ?\"></a>about what ?</h2><blockquote>\n<p>I’ve been programming since last year and I’ve loved technology and programming every since.I like to be a geek.Also I like mountain climbing,it’s very funny~</p>\n</blockquote>\n<h2 id=\"关于博客名的解释\"><a href=\"#关于博客名的解释\" class=\"headerlink\" title=\"关于博客名的解释\"></a>关于博客名的解释</h2><blockquote>\n<p>因为博主的名字中有个“霖”字,而”bubble”是气泡的意思,球状,又像个0,所以就突然取<code>bubblelin</code>为博客名,用前面的翻译就是“0”</p>\n</blockquote>\n<h2 id=\"音乐是最放松的放松\"><a href=\"#音乐是最放松的放松\" class=\"headerlink\" title=\"音乐是最放松的放松\"></a>音乐是最放松的放松</h2><blockquote>\n<p>喜欢听音乐,喜欢听jay的歌曲,to enjoy</p>\n</blockquote>\n<p><img src=\"http://ww3.sinaimg.cn/large/6a3d492dgw1eo14c1qlg3j218g0tktgw.jpg\" alt=\"Alt text\"><br><!-- <div id=\"aplayer0\" class=\"aplayer\" style=\"margin-bottom: 20px;\"></div><script>var aplayer0 = new APlayer({element: document.getElementById(\"aplayer0\"),narrow: false,autoplay: false,showlrc: 0,music : {title: \"爱情废柴\",author: \"周杰伦\",url: \"http://sc1.111ttt.com/2016/1/06/24/199240143042.mp3\",pic: \"\"}});aplayer0.init();</script> –></p>\n<h2 id=\"歌词精选\"><a href=\"#歌词精选\" class=\"headerlink\" title=\"歌词精选\"></a>歌词精选</h2><div align = center><br>没有你的冬天<br>我会一直唱着唱着<br>直到你出现<br>为你封麦 只唱你爱<br>Goodbye Don’t Cry 哭个痛快<br>曲终人散 你也走散<br>我承认我是爱情里的废柴<br>你的离开 喊得太快<br>我的依赖 还在耍赖<br>眼泪打转 转不回来<br>你的笑容灿烂<br></div>\n"},{"title":"categories","date":"2016-05-21T03:55:41.000Z","type":"categories","comments":0,"_content":"","source":"categories/index.md","raw":"---\ntitle: categories\ndate: 2016-05-21 11:55:41\ntype: \"categories\"\ncomments: false\n---\n","updated":"2018-01-10T03:20:19.000Z","path":"categories/index.html","layout":"page","_id":"cjc8oaidj00033sashfoynj21","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script>","excerpt":"","more":""},{"title":"tags","date":"2016-05-21T03:56:17.000Z","type":"tags","comments":0,"_content":"","source":"tags/index.md","raw":"---\ntitle: tags\ndate: 2016-05-21 11:56:17\ntype: \"tags\"\ncomments: false\n---\n","updated":"2018-01-10T03:20:19.000Z","path":"tags/index.html","layout":"page","_id":"cjc8oaidt00073sask0h7kixe","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script>","excerpt":"","more":""}],"Post":[{"title":"JavaWeb开发掌握的技能","date":"2016-09-01T15:07:13.000Z","_content":"### Java开发语言\n\nJava是一门面向对象编程语言,是进行Java开发的基础。Java的工作原理主要由4个方面:\n\n1. Java编程语言\n2. Java类文件格式\n3. Java虚拟机\n4. Java应用程序接口\n\n### Web基础\n\n1. html:HyperText Markup Language,包含的元素,网页显示的内容,比如标题,段落等,“超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素.\n2. css:Cascading Style Sheets,网页元素的样式,负责网页(HTML或XML)元素的布局,比如字体颜色,表格美化等.\n3. JavaScript:脚本语言,网页元素的行为,负责处理网页元素的事件,以及行为,比如点击,弹框.拖拽等.\n3. jQuery:JavaScript和查询(Query),辅助JavaScript开发的库.jQuery极大简化了JavaScript编程.\n5. AJAX:是异步的JavaScript和XML,用于创建快速动态网页的技术.在不重新加载整个页面的情况下,AJAX是与服务器交换部分数据并更新部分网页.\n\n### J2EE平台\n\n1. JSP:Java Server Pages,java服务器页面,其根本是一个简化的Servlet设计.JSP与PHP,ASP,ASP.NET等语言类似,运行在服务器端的语言\n2. Servlet:其由来是用Java编写的,在服务器上运行的小程序.Servlet是指任何实现了这个Servlet接口的类,其主要功能在于交互式地浏览和修改数据,生成动态Web内容\n\n### 数据库\n\n1. SQL:结构化查询语言,与数据库打交道必须掌握\n2. MySQL:关系型数据库管理系统,其中MyISAM拥有较高的插入,查询速度,但不支持事务;InnoDB是事务型数据库的首选引擎,支持ACID事务,支持行级锁定.\n3. Oracle Database:关系数据库管理系统\n4. Navicat:数据库可视化的管理工具\n\n### 服务器\n\n1. Tomcat:开发和调试JSP 程序\n\n### 操作系统\n\n1. linux:熟悉基本的操作,以及简单的应用开打\n2. windows:主要是还是用微软的操作系统开发,熟悉\n3. OS X:目前没有机会使用\n\n\n### 开源框架\n\n1. Struts2:基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互.\n2. Spring:Spring是一个容器,一个轻量级控制反转(IoC)和面向切面(AOP)的容器框架.\n3. Hibernate:是一个对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQL语句,自动执行.\n4. SpringMVC:Spring框架提供了构建Web应用程序的全功能MVC模块.使用Spring可插入的MVC架构,从而在使用Spring进行WEB开发时,可以选择使用Spring的SpringMVC框架或集成其他MVC开发框架,如Struts1,Struts2等.\n5. Mybatis:支持自定义SQL、存储过程和高级映射的持久化框架\n\n### IDE开发工具\n\n1. Eclipse:开源免费\n2. IntelliJ IDEA:收费\n\n\n### 代码管理工具\n\n1. SVN:Subversion,是一个开放源代码的版本控制系统。用于多人共同开发一个项目,在服务端共享资源\n2. Git:是一个开源的分布式版本控制系统,强大的分布式管理方式,强大好用过的功能,如克隆、分支、合并等\n3. Maven:Maven是一个项目管理工具,它包含了一个项目对象模型,一组标准集合,一个项目生命周期,一个依赖管理系统,和用来运行定义在生命周期阶段中插件目标的逻辑。\n\n\n### 总结\n\n成为Javaweb开发人员不可能一蹴而就,没有捷径。程序员需要学习和掌握很多不同的技术。而所有这些都需要时间来学习。 但成为Java web开发人员是一个非常有意义的事业,让我们一起热爱编程。\n","source":"_posts/JavaWeb开发掌握的技能.md","raw":"---\ntitle: JavaWeb开发掌握的技能\ndate: 2016-09-01 23:07:13\ncategories: 编程 \ntags: [Java] \n---\n### Java开发语言\n\nJava是一门面向对象编程语言,是进行Java开发的基础。Java的工作原理主要由4个方面:\n\n1. Java编程语言\n2. Java类文件格式\n3. Java虚拟机\n4. Java应用程序接口\n\n### Web基础\n\n1. html:HyperText Markup Language,包含的元素,网页显示的内容,比如标题,段落等,“超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素.\n2. css:Cascading Style Sheets,网页元素的样式,负责网页(HTML或XML)元素的布局,比如字体颜色,表格美化等.\n3. JavaScript:脚本语言,网页元素的行为,负责处理网页元素的事件,以及行为,比如点击,弹框.拖拽等.\n3. jQuery:JavaScript和查询(Query),辅助JavaScript开发的库.jQuery极大简化了JavaScript编程.\n5. AJAX:是异步的JavaScript和XML,用于创建快速动态网页的技术.在不重新加载整个页面的情况下,AJAX是与服务器交换部分数据并更新部分网页.\n\n### J2EE平台\n\n1. JSP:Java Server Pages,java服务器页面,其根本是一个简化的Servlet设计.JSP与PHP,ASP,ASP.NET等语言类似,运行在服务器端的语言\n2. Servlet:其由来是用Java编写的,在服务器上运行的小程序.Servlet是指任何实现了这个Servlet接口的类,其主要功能在于交互式地浏览和修改数据,生成动态Web内容\n\n### 数据库\n\n1. SQL:结构化查询语言,与数据库打交道必须掌握\n2. MySQL:关系型数据库管理系统,其中MyISAM拥有较高的插入,查询速度,但不支持事务;InnoDB是事务型数据库的首选引擎,支持ACID事务,支持行级锁定.\n3. Oracle Database:关系数据库管理系统\n4. Navicat:数据库可视化的管理工具\n\n### 服务器\n\n1. Tomcat:开发和调试JSP 程序\n\n### 操作系统\n\n1. linux:熟悉基本的操作,以及简单的应用开打\n2. windows:主要是还是用微软的操作系统开发,熟悉\n3. OS X:目前没有机会使用\n\n\n### 开源框架\n\n1. Struts2:基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互.\n2. Spring:Spring是一个容器,一个轻量级控制反转(IoC)和面向切面(AOP)的容器框架.\n3. Hibernate:是一个对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQL语句,自动执行.\n4. SpringMVC:Spring框架提供了构建Web应用程序的全功能MVC模块.使用Spring可插入的MVC架构,从而在使用Spring进行WEB开发时,可以选择使用Spring的SpringMVC框架或集成其他MVC开发框架,如Struts1,Struts2等.\n5. Mybatis:支持自定义SQL、存储过程和高级映射的持久化框架\n\n### IDE开发工具\n\n1. Eclipse:开源免费\n2. IntelliJ IDEA:收费\n\n\n### 代码管理工具\n\n1. SVN:Subversion,是一个开放源代码的版本控制系统。用于多人共同开发一个项目,在服务端共享资源\n2. Git:是一个开源的分布式版本控制系统,强大的分布式管理方式,强大好用过的功能,如克隆、分支、合并等\n3. Maven:Maven是一个项目管理工具,它包含了一个项目对象模型,一组标准集合,一个项目生命周期,一个依赖管理系统,和用来运行定义在生命周期阶段中插件目标的逻辑。\n\n\n### 总结\n\n成为Javaweb开发人员不可能一蹴而就,没有捷径。程序员需要学习和掌握很多不同的技术。而所有这些都需要时间来学习。 但成为Java web开发人员是一个非常有意义的事业,让我们一起热爱编程。\n","slug":"JavaWeb开发掌握的技能","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaida00003sas1kvf2kvd","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"Java开发语言\"><a href=\"#Java开发语言\" class=\"headerlink\" title=\"Java开发语言\"></a>Java开发语言</h3><p>Java是一门面向对象编程语言,是进行Java开发的基础。Java的工作原理主要由4个方面:</p>\n<ol>\n<li>Java编程语言</li>\n<li>Java类文件格式</li>\n<li>Java虚拟机</li>\n<li>Java应用程序接口</li>\n</ol>\n<h3 id=\"Web基础\"><a href=\"#Web基础\" class=\"headerlink\" title=\"Web基础\"></a>Web基础</h3><ol>\n<li>html:HyperText Markup Language,包含的元素,网页显示的内容,比如标题,段落等,“超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素.</li>\n<li>css:Cascading Style Sheets,网页元素的样式,负责网页(HTML或XML)元素的布局,比如字体颜色,表格美化等.</li>\n<li>JavaScript:脚本语言,网页元素的行为,负责处理网页元素的事件,以及行为,比如点击,弹框.拖拽等.</li>\n<li>jQuery:JavaScript和查询(Query),辅助JavaScript开发的库.jQuery极大简化了JavaScript编程.</li>\n<li>AJAX:是异步的JavaScript和XML,用于创建快速动态网页的技术.在不重新加载整个页面的情况下,AJAX是与服务器交换部分数据并更新部分网页.</li>\n</ol>\n<h3 id=\"J2EE平台\"><a href=\"#J2EE平台\" class=\"headerlink\" title=\"J2EE平台\"></a>J2EE平台</h3><ol>\n<li>JSP:Java Server Pages,java服务器页面,其根本是一个简化的Servlet设计.JSP与PHP,ASP,ASP.NET等语言类似,运行在服务器端的语言</li>\n<li>Servlet:其由来是用Java编写的,在服务器上运行的小程序.Servlet是指任何实现了这个Servlet接口的类,其主要功能在于交互式地浏览和修改数据,生成动态Web内容</li>\n</ol>\n<h3 id=\"数据库\"><a href=\"#数据库\" class=\"headerlink\" title=\"数据库\"></a>数据库</h3><ol>\n<li>SQL:结构化查询语言,与数据库打交道必须掌握</li>\n<li>MySQL:关系型数据库管理系统,其中MyISAM拥有较高的插入,查询速度,但不支持事务;InnoDB是事务型数据库的首选引擎,支持ACID事务,支持行级锁定.</li>\n<li>Oracle Database:关系数据库管理系统</li>\n<li>Navicat:数据库可视化的管理工具</li>\n</ol>\n<h3 id=\"服务器\"><a href=\"#服务器\" class=\"headerlink\" title=\"服务器\"></a>服务器</h3><ol>\n<li>Tomcat:开发和调试JSP 程序</li>\n</ol>\n<h3 id=\"操作系统\"><a href=\"#操作系统\" class=\"headerlink\" title=\"操作系统\"></a>操作系统</h3><ol>\n<li>linux:熟悉基本的操作,以及简单的应用开打</li>\n<li>windows:主要是还是用微软的操作系统开发,熟悉</li>\n<li>OS X:目前没有机会使用</li>\n</ol>\n<h3 id=\"开源框架\"><a href=\"#开源框架\" class=\"headerlink\" title=\"开源框架\"></a>开源框架</h3><ol>\n<li>Struts2:基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互.</li>\n<li>Spring:Spring是一个容器,一个轻量级控制反转(IoC)和面向切面(AOP)的容器框架.</li>\n<li>Hibernate:是一个对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQL语句,自动执行.</li>\n<li>SpringMVC:Spring框架提供了构建Web应用程序的全功能MVC模块.使用Spring可插入的MVC架构,从而在使用Spring进行WEB开发时,可以选择使用Spring的SpringMVC框架或集成其他MVC开发框架,如Struts1,Struts2等.</li>\n<li>Mybatis:支持自定义SQL、存储过程和高级映射的持久化框架</li>\n</ol>\n<h3 id=\"IDE开发工具\"><a href=\"#IDE开发工具\" class=\"headerlink\" title=\"IDE开发工具\"></a>IDE开发工具</h3><ol>\n<li>Eclipse:开源免费</li>\n<li>IntelliJ IDEA:收费</li>\n</ol>\n<h3 id=\"代码管理工具\"><a href=\"#代码管理工具\" class=\"headerlink\" title=\"代码管理工具\"></a>代码管理工具</h3><ol>\n<li>SVN:Subversion,是一个开放源代码的版本控制系统。用于多人共同开发一个项目,在服务端共享资源</li>\n<li>Git:是一个开源的分布式版本控制系统,强大的分布式管理方式,强大好用过的功能,如克隆、分支、合并等</li>\n<li>Maven:Maven是一个项目管理工具,它包含了一个项目对象模型,一组标准集合,一个项目生命周期,一个依赖管理系统,和用来运行定义在生命周期阶段中插件目标的逻辑。</li>\n</ol>\n<h3 id=\"总结\"><a href=\"#总结\" class=\"headerlink\" title=\"总结\"></a>总结</h3><p>成为Javaweb开发人员不可能一蹴而就,没有捷径。程序员需要学习和掌握很多不同的技术。而所有这些都需要时间来学习。 但成为Java web开发人员是一个非常有意义的事业,让我们一起热爱编程。</p>\n","excerpt":"","more":"<h3 id=\"Java开发语言\"><a href=\"#Java开发语言\" class=\"headerlink\" title=\"Java开发语言\"></a>Java开发语言</h3><p>Java是一门面向对象编程语言,是进行Java开发的基础。Java的工作原理主要由4个方面:</p>\n<ol>\n<li>Java编程语言</li>\n<li>Java类文件格式</li>\n<li>Java虚拟机</li>\n<li>Java应用程序接口</li>\n</ol>\n<h3 id=\"Web基础\"><a href=\"#Web基础\" class=\"headerlink\" title=\"Web基础\"></a>Web基础</h3><ol>\n<li>html:HyperText Markup Language,包含的元素,网页显示的内容,比如标题,段落等,“超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素.</li>\n<li>css:Cascading Style Sheets,网页元素的样式,负责网页(HTML或XML)元素的布局,比如字体颜色,表格美化等.</li>\n<li>JavaScript:脚本语言,网页元素的行为,负责处理网页元素的事件,以及行为,比如点击,弹框.拖拽等.</li>\n<li>jQuery:JavaScript和查询(Query),辅助JavaScript开发的库.jQuery极大简化了JavaScript编程.</li>\n<li>AJAX:是异步的JavaScript和XML,用于创建快速动态网页的技术.在不重新加载整个页面的情况下,AJAX是与服务器交换部分数据并更新部分网页.</li>\n</ol>\n<h3 id=\"J2EE平台\"><a href=\"#J2EE平台\" class=\"headerlink\" title=\"J2EE平台\"></a>J2EE平台</h3><ol>\n<li>JSP:Java Server Pages,java服务器页面,其根本是一个简化的Servlet设计.JSP与PHP,ASP,ASP.NET等语言类似,运行在服务器端的语言</li>\n<li>Servlet:其由来是用Java编写的,在服务器上运行的小程序.Servlet是指任何实现了这个Servlet接口的类,其主要功能在于交互式地浏览和修改数据,生成动态Web内容</li>\n</ol>\n<h3 id=\"数据库\"><a href=\"#数据库\" class=\"headerlink\" title=\"数据库\"></a>数据库</h3><ol>\n<li>SQL:结构化查询语言,与数据库打交道必须掌握</li>\n<li>MySQL:关系型数据库管理系统,其中MyISAM拥有较高的插入,查询速度,但不支持事务;InnoDB是事务型数据库的首选引擎,支持ACID事务,支持行级锁定.</li>\n<li>Oracle Database:关系数据库管理系统</li>\n<li>Navicat:数据库可视化的管理工具</li>\n</ol>\n<h3 id=\"服务器\"><a href=\"#服务器\" class=\"headerlink\" title=\"服务器\"></a>服务器</h3><ol>\n<li>Tomcat:开发和调试JSP 程序</li>\n</ol>\n<h3 id=\"操作系统\"><a href=\"#操作系统\" class=\"headerlink\" title=\"操作系统\"></a>操作系统</h3><ol>\n<li>linux:熟悉基本的操作,以及简单的应用开打</li>\n<li>windows:主要是还是用微软的操作系统开发,熟悉</li>\n<li>OS X:目前没有机会使用</li>\n</ol>\n<h3 id=\"开源框架\"><a href=\"#开源框架\" class=\"headerlink\" title=\"开源框架\"></a>开源框架</h3><ol>\n<li>Struts2:基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互.</li>\n<li>Spring:Spring是一个容器,一个轻量级控制反转(IoC)和面向切面(AOP)的容器框架.</li>\n<li>Hibernate:是一个对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQL语句,自动执行.</li>\n<li>SpringMVC:Spring框架提供了构建Web应用程序的全功能MVC模块.使用Spring可插入的MVC架构,从而在使用Spring进行WEB开发时,可以选择使用Spring的SpringMVC框架或集成其他MVC开发框架,如Struts1,Struts2等.</li>\n<li>Mybatis:支持自定义SQL、存储过程和高级映射的持久化框架</li>\n</ol>\n<h3 id=\"IDE开发工具\"><a href=\"#IDE开发工具\" class=\"headerlink\" title=\"IDE开发工具\"></a>IDE开发工具</h3><ol>\n<li>Eclipse:开源免费</li>\n<li>IntelliJ IDEA:收费</li>\n</ol>\n<h3 id=\"代码管理工具\"><a href=\"#代码管理工具\" class=\"headerlink\" title=\"代码管理工具\"></a>代码管理工具</h3><ol>\n<li>SVN:Subversion,是一个开放源代码的版本控制系统。用于多人共同开发一个项目,在服务端共享资源</li>\n<li>Git:是一个开源的分布式版本控制系统,强大的分布式管理方式,强大好用过的功能,如克隆、分支、合并等</li>\n<li>Maven:Maven是一个项目管理工具,它包含了一个项目对象模型,一组标准集合,一个项目生命周期,一个依赖管理系统,和用来运行定义在生命周期阶段中插件目标的逻辑。</li>\n</ol>\n<h3 id=\"总结\"><a href=\"#总结\" class=\"headerlink\" title=\"总结\"></a>总结</h3><p>成为Javaweb开发人员不可能一蹴而就,没有捷径。程序员需要学习和掌握很多不同的技术。而所有这些都需要时间来学习。 但成为Java web开发人员是一个非常有意义的事业,让我们一起热爱编程。</p>\n"},{"title":"记录我在Github上搭建个人博客","date":"2016-07-25T14:30:15.000Z","_content":"### 写在前面\n很庆幸生活在一个互联网高度发达的时代,网上有海量的信息,不乏是自己的兴趣的所在,尤其遇到我是喜欢学习的知识,所以我几乎每天都会打开电脑接受知识的洗礼,也是为了做一个活到老学到老的人~\n\n### Github的背景与理解\n>Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理。在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中。目前,包括Rubinius和Merb在内的很多知名项目都使用了Git。Git同样可以被诸如Capistrano和Vlad the Deployer这样的部署工具所使用。Github就是托管各种git库,并提供一个web界面的一款易于使用的git图形客户端。当你做了一个程序放在git上,别人感兴趣,对你的代码进行了一些修改,提交上去,你看了觉得很好,就立刻用提交的代码合并进去。目前,Github拥有140多万开发者用户,可以说Github是一个社交化的编程网站。\n\n### 搭建个人博客\n* 1.注册Github账号,按照提示很快就得到了一个免费的域名,比如我的:bubblelin.github.io\n* 2.New repository,命名为bubblelin.github.io\n* 3.在地址栏打开bubblelin.github.io,这样就到达了个人博客网站了!\n\n### 安装Git和Node\n我用的版本:\n\n* Git: Git-2.9.2-64-bit\n* Node: node-v6.3.1-x64\n\n一直默认安装就行了\n\n### Git常用的命令\n\n* 配置用户信息\n``` bash\ngit config --global user.name \"userName\"\ngit config --global user.email \"emailAddress\"\n```\n\n* 1.添加文件到stage\n``` bash\n$ git add\n```\n\n* 2.查询stage或版本库里的文件有无改动\n``` bash\n$ git status\n```\n\n* 3.提交文件到git版本库\n``` bash\n$ git commit\n```\n\n* 4.关联一个远程库\n``` bash\n$ git remote add origin https://github.com/bubblelin/bubblelin.github.io.git\n```\n\n* 5.第一次推送,以后推送,可以没有‘-u’\n``` bash\n$ git push -u origin master\n```\n\n\n### Hexo常用的命令\n* 1.在source目录下创建新博客\n``` bash\n$ hexo new \"My New Post\"\n```\n\n* 2.生成博客\n``` bash\n$ hexo generate\n```\n\n* 3.部署本地服务器\n``` bash\n$ hexo server\n```\n\n* 4.部署到远程GitHub\n``` bash\n$ hexo deploy\n```\n\n备注:hexo命令部署到远程Github,应部署到master分支,git命令推送源码到分支hexo上\n推荐教程:(Hexo 搭建博客-基础配置篇 - 简书)[http://www.jianshu.com/p/df3edc4286d2]\n","source":"_posts/Github上搭建个人博客.md","raw":"---\ntitle: 记录我在Github上搭建个人博客\ndate: 2016-07-25 22:30:15\ncategories: hexo\ntags: [博客之路,HEXO]\n---\n### 写在前面\n很庆幸生活在一个互联网高度发达的时代,网上有海量的信息,不乏是自己的兴趣的所在,尤其遇到我是喜欢学习的知识,所以我几乎每天都会打开电脑接受知识的洗礼,也是为了做一个活到老学到老的人~\n\n### Github的背景与理解\n>Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理。在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中。目前,包括Rubinius和Merb在内的很多知名项目都使用了Git。Git同样可以被诸如Capistrano和Vlad the Deployer这样的部署工具所使用。Github就是托管各种git库,并提供一个web界面的一款易于使用的git图形客户端。当你做了一个程序放在git上,别人感兴趣,对你的代码进行了一些修改,提交上去,你看了觉得很好,就立刻用提交的代码合并进去。目前,Github拥有140多万开发者用户,可以说Github是一个社交化的编程网站。\n\n### 搭建个人博客\n* 1.注册Github账号,按照提示很快就得到了一个免费的域名,比如我的:bubblelin.github.io\n* 2.New repository,命名为bubblelin.github.io\n* 3.在地址栏打开bubblelin.github.io,这样就到达了个人博客网站了!\n\n### 安装Git和Node\n我用的版本:\n\n* Git: Git-2.9.2-64-bit\n* Node: node-v6.3.1-x64\n\n一直默认安装就行了\n\n### Git常用的命令\n\n* 配置用户信息\n``` bash\ngit config --global user.name \"userName\"\ngit config --global user.email \"emailAddress\"\n```\n\n* 1.添加文件到stage\n``` bash\n$ git add\n```\n\n* 2.查询stage或版本库里的文件有无改动\n``` bash\n$ git status\n```\n\n* 3.提交文件到git版本库\n``` bash\n$ git commit\n```\n\n* 4.关联一个远程库\n``` bash\n$ git remote add origin https://github.com/bubblelin/bubblelin.github.io.git\n```\n\n* 5.第一次推送,以后推送,可以没有‘-u’\n``` bash\n$ git push -u origin master\n```\n\n\n### Hexo常用的命令\n* 1.在source目录下创建新博客\n``` bash\n$ hexo new \"My New Post\"\n```\n\n* 2.生成博客\n``` bash\n$ hexo generate\n```\n\n* 3.部署本地服务器\n``` bash\n$ hexo server\n```\n\n* 4.部署到远程GitHub\n``` bash\n$ hexo deploy\n```\n\n备注:hexo命令部署到远程Github,应部署到master分支,git命令推送源码到分支hexo上\n推荐教程:(Hexo 搭建博客-基础配置篇 - 简书)[http://www.jianshu.com/p/df3edc4286d2]\n","slug":"Github上搭建个人博客","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaidg00023saszs7qpv82","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"写在前面\"><a href=\"#写在前面\" class=\"headerlink\" title=\"写在前面\"></a>写在前面</h3><p>很庆幸生活在一个互联网高度发达的时代,网上有海量的信息,不乏是自己的兴趣的所在,尤其遇到我是喜欢学习的知识,所以我几乎每天都会打开电脑接受知识的洗礼,也是为了做一个活到老学到老的人~</p>\n<h3 id=\"Github的背景与理解\"><a href=\"#Github的背景与理解\" class=\"headerlink\" title=\"Github的背景与理解\"></a>Github的背景与理解</h3><blockquote>\n<p>Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理。在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中。目前,包括Rubinius和Merb在内的很多知名项目都使用了Git。Git同样可以被诸如Capistrano和Vlad the Deployer这样的部署工具所使用。Github就是托管各种git库,并提供一个web界面的一款易于使用的git图形客户端。当你做了一个程序放在git上,别人感兴趣,对你的代码进行了一些修改,提交上去,你看了觉得很好,就立刻用提交的代码合并进去。目前,Github拥有140多万开发者用户,可以说Github是一个社交化的编程网站。</p>\n</blockquote>\n<h3 id=\"搭建个人博客\"><a href=\"#搭建个人博客\" class=\"headerlink\" title=\"搭建个人博客\"></a>搭建个人博客</h3><ul>\n<li>1.注册Github账号,按照提示很快就得到了一个免费的域名,比如我的:bubblelin.github.io</li>\n<li>2.New repository,命名为bubblelin.github.io</li>\n<li>3.在地址栏打开bubblelin.github.io,这样就到达了个人博客网站了!</li>\n</ul>\n<h3 id=\"安装Git和Node\"><a href=\"#安装Git和Node\" class=\"headerlink\" title=\"安装Git和Node\"></a>安装Git和Node</h3><p>我用的版本:</p>\n<ul>\n<li>Git: Git-2.9.2-64-bit</li>\n<li>Node: node-v6.3.1-x64</li>\n</ul>\n<p>一直默认安装就行了</p>\n<h3 id=\"Git常用的命令\"><a href=\"#Git常用的命令\" class=\"headerlink\" title=\"Git常用的命令\"></a>Git常用的命令</h3><ul>\n<li><p>配置用户信息</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">git config --global user.name <span class=\"string\">\"userName\"</span></div><div class=\"line\">git config --global user.email <span class=\"string\">\"emailAddress\"</span></div></pre></td></tr></table></figure>\n</li>\n<li><p>1.添加文件到stage</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git add</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.查询stage或版本库里的文件有无改动</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git status</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.提交文件到git版本库</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git commit</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.关联一个远程库</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git remote add origin https://github.com/bubblelin/bubblelin.github.io.git</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.第一次推送,以后推送,可以没有‘-u’</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push -u origin master</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"Hexo常用的命令\"><a href=\"#Hexo常用的命令\" class=\"headerlink\" title=\"Hexo常用的命令\"></a>Hexo常用的命令</h3><ul>\n<li><p>1.在source目录下创建新博客</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo new <span class=\"string\">\"My New Post\"</span></div></pre></td></tr></table></figure>\n</li>\n<li><p>2.生成博客</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo generate</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.部署本地服务器</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo server</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.部署到远程GitHub</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo deploy</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>备注:hexo命令部署到远程Github,应部署到master分支,git命令推送源码到分支hexo上<br>推荐教程:(Hexo 搭建博客-基础配置篇 - 简书)[<a href=\"http://www.jianshu.com/p/df3edc4286d2\" target=\"_blank\" rel=\"external\">http://www.jianshu.com/p/df3edc4286d2</a>]</p>\n","excerpt":"","more":"<h3 id=\"写在前面\"><a href=\"#写在前面\" class=\"headerlink\" title=\"写在前面\"></a>写在前面</h3><p>很庆幸生活在一个互联网高度发达的时代,网上有海量的信息,不乏是自己的兴趣的所在,尤其遇到我是喜欢学习的知识,所以我几乎每天都会打开电脑接受知识的洗礼,也是为了做一个活到老学到老的人~</p>\n<h3 id=\"Github的背景与理解\"><a href=\"#Github的背景与理解\" class=\"headerlink\" title=\"Github的背景与理解\"></a>Github的背景与理解</h3><blockquote>\n<p>Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理。在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中。目前,包括Rubinius和Merb在内的很多知名项目都使用了Git。Git同样可以被诸如Capistrano和Vlad the Deployer这样的部署工具所使用。Github就是托管各种git库,并提供一个web界面的一款易于使用的git图形客户端。当你做了一个程序放在git上,别人感兴趣,对你的代码进行了一些修改,提交上去,你看了觉得很好,就立刻用提交的代码合并进去。目前,Github拥有140多万开发者用户,可以说Github是一个社交化的编程网站。</p>\n</blockquote>\n<h3 id=\"搭建个人博客\"><a href=\"#搭建个人博客\" class=\"headerlink\" title=\"搭建个人博客\"></a>搭建个人博客</h3><ul>\n<li>1.注册Github账号,按照提示很快就得到了一个免费的域名,比如我的:bubblelin.github.io</li>\n<li>2.New repository,命名为bubblelin.github.io</li>\n<li>3.在地址栏打开bubblelin.github.io,这样就到达了个人博客网站了!</li>\n</ul>\n<h3 id=\"安装Git和Node\"><a href=\"#安装Git和Node\" class=\"headerlink\" title=\"安装Git和Node\"></a>安装Git和Node</h3><p>我用的版本:</p>\n<ul>\n<li>Git: Git-2.9.2-64-bit</li>\n<li>Node: node-v6.3.1-x64</li>\n</ul>\n<p>一直默认安装就行了</p>\n<h3 id=\"Git常用的命令\"><a href=\"#Git常用的命令\" class=\"headerlink\" title=\"Git常用的命令\"></a>Git常用的命令</h3><ul>\n<li><p>配置用户信息</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">git config --global user.name <span class=\"string\">\"userName\"</span></div><div class=\"line\">git config --global user.email <span class=\"string\">\"emailAddress\"</span></div></pre></td></tr></table></figure>\n</li>\n<li><p>1.添加文件到stage</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git add</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.查询stage或版本库里的文件有无改动</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git status</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.提交文件到git版本库</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git commit</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.关联一个远程库</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git remote add origin https://github.com/bubblelin/bubblelin.github.io.git</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.第一次推送,以后推送,可以没有‘-u’</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push -u origin master</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"Hexo常用的命令\"><a href=\"#Hexo常用的命令\" class=\"headerlink\" title=\"Hexo常用的命令\"></a>Hexo常用的命令</h3><ul>\n<li><p>1.在source目录下创建新博客</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo new <span class=\"string\">\"My New Post\"</span></div></pre></td></tr></table></figure>\n</li>\n<li><p>2.生成博客</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo generate</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.部署本地服务器</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo server</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.部署到远程GitHub</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ hexo deploy</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>备注:hexo命令部署到远程Github,应部署到master分支,git命令推送源码到分支hexo上<br>推荐教程:(Hexo 搭建博客-基础配置篇 - 简书)[<a href=\"http://www.jianshu.com/p/df3edc4286d2\">http://www.jianshu.com/p/df3edc4286d2</a>]</p>\n"},{"title":"字符串和正则表达式","date":"2017-06-20T02:58:27.000Z","_content":"\n### 基础\n\n#### 正则表达式匹配\n  一般来说,正则表达式就是以某种方式来描述字符串。例如,“要找一个数字,他**可能**有一个负号在最前面”,则用`-?`表示。\n  在正则表达式中,`\\d`表示一位数字。但在Java中,需要用`\\\\`表示后面的字符有特殊的意义,所以一位数字应该用`\\\\d`表示。\n  要表示“一个或多个之前的表达式”,应该使用`+`。例如,“表示一个负号,后面跟着一位或多位数字”,表达式为:\n  `-?\\\\d+`\n\n  检查一个String是否匹配如上所诉的正则表达式\n```Java\npublic class IntegerMatch{\n\n public static void main(String[] args){\n System.out.println(\"-1234\".matches(\"-?\\\\d+\"));//true\n System.out.println(\"1234\".matches(\"-?\\\\d+\"));//true\n System.out.println(\"+1234\".matches(\"-?\\\\d+\"));//false\n System.out.println(\"+1234\".matches(\"(-|\\\\+)?\\\\d+\"));//true\n }\n}\n```\n前面两个字符串满足对应的正则表达式,匹配成功。第三个字符串开头`+`,它也是一个合法的字符,但对应的正则表达式不匹配。正则表达式应该描述为“可能以一个加号或减号开头”。在正则表达中,括号`()`具有分组的效果,而竖线`|`则表示“或”操作,表达式为:\n  `(-|\\\\+)?\\\\d+`\n这个正则表达式表示“字符串的起始字符**可能**是一个`-`或`+`,或者二者皆没有(因为后面跟着`?`修饰符),另外字符`+`在正则表达式中有特殊意义,所以需要用`\\\\`转义”。\n\n#### Java的split和replace方法\n+ `split()`方法,旨在将字符串从正则表达式匹配的地方切开\n```Java\npublic class Splitting(){\n\n public static String knights = \"Then, hello world !\";\n\n public static void Splitting(String regex){\n System.out.println(Arrays.toString(knights.split(regex)));\n }\n\n public static void main(String[] args){\n Splitting(\" \");//[Then,,hello,world,!]\n Splitting(\"\\\\W+\");//[Then, hello, world]\n Splitting(\"n\\\\W+\");//[The,hello,world!]\n }\n}\n```\n第二个和第三个表达式都用到了`\\W`,它的意思是“非单词字符”(如果`W`小写,`\\w`,则表示“一个单词字符”)\n\n+ `replace()`方法,旨在替换匹配正则表达式的子字符串\n```Java\npublic class Replacing(){\n\n static String s = Splitting.knights;\n\n public static void replaceFirsting(String regex, String str){\n System.out.println(s.replaceAll(regex, str));\n }\n\n public static void replaceAlling(String regex, String str){\n System.out.println(s.replaceAll(regex, str));\n }\n\n public static void main(String[] args){\n repaceFirsting(\"o\\\\w+\",\"boy\");//Then, hello wboy !\n repaceAlling(\"en|lo|ld\",\"boy\");//Thboy, helboy worboy !\n }\n}\n```\n第二个表达式用分隔符`|`,表示“或”。\n\n\n### 创建\n\n正则表达式的完整构造子列表\n* 常用字符\n\n| 表达式 | 字符\n| --- | ---\n| B | 指定字符\n| \\xhh | 十六进制值为0xhh\n| \\xhhhhh | 十六进制表示为0xhhhh的Unicode字符\n| \\t | 制表符Tab\n| \\n | 换行符\n| \\r | 回车\n| \\f | 换页\n| \\e | 转义(Esc)\n\n* 常用字符类\n\n| 表达式 | 字符\n| --- | ---\n| . | 任意字符\n| [abc] | 包含a,b,c的任何字符(同 ‘a或b或c’)\n| [^abc] | 除a,b,c之外的任何字符\n| [a-zA-Z] | 从a~z和A~Z的任何字符(范围)\n| abc[hij] | 同 ‘a或b或c或h或i或j’(合并\n| a-z&&[hij] | 任意h,i,j(交集)\n| \\s | 空白符(空格,tab,换行,回车,换页)\n| \\S | 非空白符,(同[^\\s])\n| \\d | 数字0~9\n| \\D | 非数字,(同[^0-9])\n| \\w | 词字符[a-zA-Z0-9]\n| \\W | 非词字符,(同[^\\w])\n\n### 常用\n\n#### 校验数字的表达式\n\n1. 数字:`(-?\\d*)(\\.\\d+)?`\n2. 带1-2位小数的正数或负数:`^(\\-)?\\d+(\\.\\d{1,2})?$ `\n3. 非零的正整数:`^[1-9]\\d*$` 或 `^([1-9][0-9]*){1,3}$` 或 `^\\+?[1-9][0-9]*$`\n\n#### 校验字符的表达式\n\n1. 汉字:`^[\\u4e00-\\u9fa5]{0,}$`\n2. 英文和数字:`^[A-Za-z0-9]+$` 或 `^[A-Za-z0-9]{4,40}$`\n3. 长度为3-20的所有字符:`^.{3,20}$`\n4. 中文、英文、数字但不包括下划线等符号:`^[\\u4E00-\\u9FA5A-Za-z0-9]+$` 或 `^[\\u4E00-\\u9FA5A-Za-z0-9]{2,20}$`\n5. 可以输入含有`^%&',;=?$\\\"`等字符:`[^%&',;=?$\\x22]+`\n\n#### 特殊需求表达式\n\n1. Email地址:`^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$`\n2. 域名:`[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?`\n3. InternetURL:`(h|H)(r|R)(e|E)(f|F) *= *('|\")?(\\w|\\\\|\\/|\\.)+('|\"| *|>)?`\n4. 手机号码:`^1[34578]\\d{9}$` 或 `^1(3|4|5|7|8)\\d{9}$` 或 `^1[0-9]{10}$`\n5. 5 电话号码:`^(\\(\\d{3,4}-)|\\d{3.4}-)?\\d{7,8}$` \n6. 身份证号(15位、18位数字):`(^\\d{15}$)|(^\\d{17}([0-9]|X)$)`\n7. 日期格式:`^\\d{4}-\\d{1,2}-\\d{1,2}`\n8. 中文字符的正则表达式:`[\\u4e00-\\u9fa5]`\n9. 空白行的正则表达式:`\\n\\s*\\r` (可以用来删除空白行)\n10. 首尾空白字符的正则表达式:`^\\s*|\\s*$或(^\\s*)|(\\s*$)` (可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式)\n11. IP地址:`\\d+\\.\\d+\\.\\d+\\.\\d+` (提取IP地址时有用)\n12. 中国邮政编码:`[1-9]\\d{5}(?!\\d)` (中国邮政编码为6位数字)\n13. 腾讯QQ号:`[1-9][0-9]{4,}` (腾讯QQ号从10000开始)\n","source":"_posts/Java中的字符串和表达式.md","raw":"---\ntitle: 字符串和正则表达式\ndate: 2017-06-20 10:58:27\ncategories: 编程\ntags: [Java]\n---\n\n### 基础\n\n#### 正则表达式匹配\n  一般来说,正则表达式就是以某种方式来描述字符串。例如,“要找一个数字,他**可能**有一个负号在最前面”,则用`-?`表示。\n  在正则表达式中,`\\d`表示一位数字。但在Java中,需要用`\\\\`表示后面的字符有特殊的意义,所以一位数字应该用`\\\\d`表示。\n  要表示“一个或多个之前的表达式”,应该使用`+`。例如,“表示一个负号,后面跟着一位或多位数字”,表达式为:\n  `-?\\\\d+`\n\n  检查一个String是否匹配如上所诉的正则表达式\n```Java\npublic class IntegerMatch{\n\n public static void main(String[] args){\n System.out.println(\"-1234\".matches(\"-?\\\\d+\"));//true\n System.out.println(\"1234\".matches(\"-?\\\\d+\"));//true\n System.out.println(\"+1234\".matches(\"-?\\\\d+\"));//false\n System.out.println(\"+1234\".matches(\"(-|\\\\+)?\\\\d+\"));//true\n }\n}\n```\n前面两个字符串满足对应的正则表达式,匹配成功。第三个字符串开头`+`,它也是一个合法的字符,但对应的正则表达式不匹配。正则表达式应该描述为“可能以一个加号或减号开头”。在正则表达中,括号`()`具有分组的效果,而竖线`|`则表示“或”操作,表达式为:\n  `(-|\\\\+)?\\\\d+`\n这个正则表达式表示“字符串的起始字符**可能**是一个`-`或`+`,或者二者皆没有(因为后面跟着`?`修饰符),另外字符`+`在正则表达式中有特殊意义,所以需要用`\\\\`转义”。\n\n#### Java的split和replace方法\n+ `split()`方法,旨在将字符串从正则表达式匹配的地方切开\n```Java\npublic class Splitting(){\n\n public static String knights = \"Then, hello world !\";\n\n public static void Splitting(String regex){\n System.out.println(Arrays.toString(knights.split(regex)));\n }\n\n public static void main(String[] args){\n Splitting(\" \");//[Then,,hello,world,!]\n Splitting(\"\\\\W+\");//[Then, hello, world]\n Splitting(\"n\\\\W+\");//[The,hello,world!]\n }\n}\n```\n第二个和第三个表达式都用到了`\\W`,它的意思是“非单词字符”(如果`W`小写,`\\w`,则表示“一个单词字符”)\n\n+ `replace()`方法,旨在替换匹配正则表达式的子字符串\n```Java\npublic class Replacing(){\n\n static String s = Splitting.knights;\n\n public static void replaceFirsting(String regex, String str){\n System.out.println(s.replaceAll(regex, str));\n }\n\n public static void replaceAlling(String regex, String str){\n System.out.println(s.replaceAll(regex, str));\n }\n\n public static void main(String[] args){\n repaceFirsting(\"o\\\\w+\",\"boy\");//Then, hello wboy !\n repaceAlling(\"en|lo|ld\",\"boy\");//Thboy, helboy worboy !\n }\n}\n```\n第二个表达式用分隔符`|`,表示“或”。\n\n\n### 创建\n\n正则表达式的完整构造子列表\n* 常用字符\n\n| 表达式 | 字符\n| --- | ---\n| B | 指定字符\n| \\xhh | 十六进制值为0xhh\n| \\xhhhhh | 十六进制表示为0xhhhh的Unicode字符\n| \\t | 制表符Tab\n| \\n | 换行符\n| \\r | 回车\n| \\f | 换页\n| \\e | 转义(Esc)\n\n* 常用字符类\n\n| 表达式 | 字符\n| --- | ---\n| . | 任意字符\n| [abc] | 包含a,b,c的任何字符(同 ‘a或b或c’)\n| [^abc] | 除a,b,c之外的任何字符\n| [a-zA-Z] | 从a~z和A~Z的任何字符(范围)\n| abc[hij] | 同 ‘a或b或c或h或i或j’(合并\n| a-z&&[hij] | 任意h,i,j(交集)\n| \\s | 空白符(空格,tab,换行,回车,换页)\n| \\S | 非空白符,(同[^\\s])\n| \\d | 数字0~9\n| \\D | 非数字,(同[^0-9])\n| \\w | 词字符[a-zA-Z0-9]\n| \\W | 非词字符,(同[^\\w])\n\n### 常用\n\n#### 校验数字的表达式\n\n1. 数字:`(-?\\d*)(\\.\\d+)?`\n2. 带1-2位小数的正数或负数:`^(\\-)?\\d+(\\.\\d{1,2})?$ `\n3. 非零的正整数:`^[1-9]\\d*$` 或 `^([1-9][0-9]*){1,3}$` 或 `^\\+?[1-9][0-9]*$`\n\n#### 校验字符的表达式\n\n1. 汉字:`^[\\u4e00-\\u9fa5]{0,}$`\n2. 英文和数字:`^[A-Za-z0-9]+$` 或 `^[A-Za-z0-9]{4,40}$`\n3. 长度为3-20的所有字符:`^.{3,20}$`\n4. 中文、英文、数字但不包括下划线等符号:`^[\\u4E00-\\u9FA5A-Za-z0-9]+$` 或 `^[\\u4E00-\\u9FA5A-Za-z0-9]{2,20}$`\n5. 可以输入含有`^%&',;=?$\\\"`等字符:`[^%&',;=?$\\x22]+`\n\n#### 特殊需求表达式\n\n1. Email地址:`^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$`\n2. 域名:`[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?`\n3. InternetURL:`(h|H)(r|R)(e|E)(f|F) *= *('|\")?(\\w|\\\\|\\/|\\.)+('|\"| *|>)?`\n4. 手机号码:`^1[34578]\\d{9}$` 或 `^1(3|4|5|7|8)\\d{9}$` 或 `^1[0-9]{10}$`\n5. 5 电话号码:`^(\\(\\d{3,4}-)|\\d{3.4}-)?\\d{7,8}$` \n6. 身份证号(15位、18位数字):`(^\\d{15}$)|(^\\d{17}([0-9]|X)$)`\n7. 日期格式:`^\\d{4}-\\d{1,2}-\\d{1,2}`\n8. 中文字符的正则表达式:`[\\u4e00-\\u9fa5]`\n9. 空白行的正则表达式:`\\n\\s*\\r` (可以用来删除空白行)\n10. 首尾空白字符的正则表达式:`^\\s*|\\s*$或(^\\s*)|(\\s*$)` (可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式)\n11. IP地址:`\\d+\\.\\d+\\.\\d+\\.\\d+` (提取IP地址时有用)\n12. 中国邮政编码:`[1-9]\\d{5}(?!\\d)` (中国邮政编码为6位数字)\n13. 腾讯QQ号:`[1-9][0-9]{4,}` (腾讯QQ号从10000开始)\n","slug":"Java中的字符串和表达式","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaids00063sas2dedzcm0","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"基础\"><a href=\"#基础\" class=\"headerlink\" title=\"基础\"></a>基础</h3><h4 id=\"正则表达式匹配\"><a href=\"#正则表达式匹配\" class=\"headerlink\" title=\"正则表达式匹配\"></a>正则表达式匹配</h4><p>  一般来说,正则表达式就是以某种方式来描述字符串。例如,“要找一个数字,他<strong>可能</strong>有一个负号在最前面”,则用<code>-?</code>表示。<br>  在正则表达式中,<code>\\d</code>表示一位数字。但在Java中,需要用<code>\\\\</code>表示后面的字符有特殊的意义,所以一位数字应该用<code>\\\\d</code>表示。<br>  要表示“一个或多个之前的表达式”,应该使用<code>+</code>。例如,“表示一个负号,后面跟着一位或多位数字”,表达式为:<br>  <code>-?\\\\d+</code></p>\n<p>  检查一个String是否匹配如上所诉的正则表达式<br><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">IntegerMatch</span></span>{</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">main</span><span class=\"params\">(String[] args)</span></span>{</div><div class=\"line\"> System.out.println(<span class=\"string\">\"-1234\"</span>.matches(<span class=\"string\">\"-?\\\\d+\"</span>));<span class=\"comment\">//true</span></div><div class=\"line\"> System.out.println(<span class=\"string\">\"1234\"</span>.matches(<span class=\"string\">\"-?\\\\d+\"</span>));<span class=\"comment\">//true</span></div><div class=\"line\"> System.out.println(<span class=\"string\">\"+1234\"</span>.matches(<span class=\"string\">\"-?\\\\d+\"</span>));<span class=\"comment\">//false</span></div><div class=\"line\"> System.out.println(<span class=\"string\">\"+1234\"</span>.matches(<span class=\"string\">\"(-|\\\\+)?\\\\d+\"</span>));<span class=\"comment\">//true</span></div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure></p>\n<p>前面两个字符串满足对应的正则表达式,匹配成功。第三个字符串开头<code>+</code>,它也是一个合法的字符,但对应的正则表达式不匹配。正则表达式应该描述为“可能以一个加号或减号开头”。在正则表达中,括号<code>()</code>具有分组的效果,而竖线<code>|</code>则表示“或”操作,表达式为:<br>  <code>(-|\\\\+)?\\\\d+</code><br>这个正则表达式表示“字符串的起始字符<strong>可能</strong>是一个<code>-</code>或<code>+</code>,或者二者皆没有(因为后面跟着<code>?</code>修饰符),另外字符<code>+</code>在正则表达式中有特殊意义,所以需要用<code>\\\\</code>转义”。</p>\n<h4 id=\"Java的split和replace方法\"><a href=\"#Java的split和replace方法\" class=\"headerlink\" title=\"Java的split和replace方法\"></a>Java的split和replace方法</h4><ul>\n<li><code>split()</code>方法,旨在将字符串从正则表达式匹配的地方切开<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> class <span class=\"title\">Splitting</span><span class=\"params\">()</span></span>{</div><div class=\"line\"></div><div class=\"line\"> <span class=\"keyword\">public</span> <span class=\"keyword\">static</span> String knights = <span class=\"string\">\"Then, hello world !\"</span>;</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">Splitting</span><span class=\"params\">(String regex)</span></span>{</div><div class=\"line\"> System.out.println(Arrays.toString(knights.split(regex)));</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">main</span><span class=\"params\">(String[] args)</span></span>{</div><div class=\"line\"> Splitting(<span class=\"string\">\" \"</span>);<span class=\"comment\">//[Then,,hello,world,!]</span></div><div class=\"line\"> Splitting(<span class=\"string\">\"\\\\W+\"</span>);<span class=\"comment\">//[Then, hello, world]</span></div><div class=\"line\"> Splitting(<span class=\"string\">\"n\\\\W+\"</span>);<span class=\"comment\">//[The,hello,world!]</span></div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>第二个和第三个表达式都用到了<code>\\W</code>,它的意思是“非单词字符”(如果<code>W</code>小写,<code>\\w</code>,则表示“一个单词字符”)</p>\n<ul>\n<li><code>replace()</code>方法,旨在替换匹配正则表达式的子字符串<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> class <span class=\"title\">Replacing</span><span class=\"params\">()</span></span>{</div><div class=\"line\"></div><div class=\"line\"> <span class=\"keyword\">static</span> String s = Splitting.knights;</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">replaceFirsting</span><span class=\"params\">(String regex, String str)</span></span>{</div><div class=\"line\"> System.out.println(s.replaceAll(regex, str));</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">replaceAlling</span><span class=\"params\">(String regex, String str)</span></span>{</div><div class=\"line\"> System.out.println(s.replaceAll(regex, str));</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">main</span><span class=\"params\">(String[] args)</span></span>{</div><div class=\"line\"> repaceFirsting(<span class=\"string\">\"o\\\\w+\"</span>,<span class=\"string\">\"boy\"</span>);<span class=\"comment\">//Then, hello wboy !</span></div><div class=\"line\"> repaceAlling(<span class=\"string\">\"en|lo|ld\"</span>,<span class=\"string\">\"boy\"</span>);<span class=\"comment\">//Thboy, helboy worboy !</span></div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>第二个表达式用分隔符<code>|</code>,表示“或”。</p>\n<h3 id=\"创建\"><a href=\"#创建\" class=\"headerlink\" title=\"创建\"></a>创建</h3><p>正则表达式的完整构造子列表</p>\n<ul>\n<li>常用字符</li>\n</ul>\n<table>\n<thead>\n<tr>\n<th>表达式</th>\n<th>字符</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>B</td>\n<td>指定字符</td>\n</tr>\n<tr>\n<td>\\xhh</td>\n<td>十六进制值为0xhh</td>\n</tr>\n<tr>\n<td>\\xhhhhh</td>\n<td>十六进制表示为0xhhhh的Unicode字符</td>\n</tr>\n<tr>\n<td>\\t</td>\n<td>制表符Tab</td>\n</tr>\n<tr>\n<td>\\n</td>\n<td>换行符</td>\n</tr>\n<tr>\n<td>\\r</td>\n<td>回车</td>\n</tr>\n<tr>\n<td>\\f</td>\n<td>换页</td>\n</tr>\n<tr>\n<td>\\e</td>\n<td>转义(Esc)</td>\n</tr>\n</tbody>\n</table>\n<ul>\n<li>常用字符类</li>\n</ul>\n<table>\n<thead>\n<tr>\n<th>表达式</th>\n<th>字符</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>.</td>\n<td>任意字符</td>\n</tr>\n<tr>\n<td>[abc]</td>\n<td>包含a,b,c的任何字符(同 ‘a或b或c’)</td>\n</tr>\n<tr>\n<td>[^abc]</td>\n<td>除a,b,c之外的任何字符</td>\n</tr>\n<tr>\n<td>[a-zA-Z]</td>\n<td>从a~z和A~Z的任何字符(范围)</td>\n</tr>\n<tr>\n<td>abc[hij]</td>\n<td>同 ‘a或b或c或h或i或j’(合并</td>\n</tr>\n<tr>\n<td>a-z&&[hij]</td>\n<td>任意h,i,j(交集)</td>\n</tr>\n<tr>\n<td>\\s</td>\n<td>空白符(空格,tab,换行,回车,换页)</td>\n</tr>\n<tr>\n<td>\\S</td>\n<td>非空白符,(同[^\\s])</td>\n</tr>\n<tr>\n<td>\\d</td>\n<td>数字0~9</td>\n</tr>\n<tr>\n<td>\\D</td>\n<td>非数字,(同[^0-9])</td>\n</tr>\n<tr>\n<td>\\w</td>\n<td>词字符[a-zA-Z0-9]</td>\n</tr>\n<tr>\n<td>\\W</td>\n<td>非词字符,(同[^\\w])</td>\n</tr>\n</tbody>\n</table>\n<h3 id=\"常用\"><a href=\"#常用\" class=\"headerlink\" title=\"常用\"></a>常用</h3><h4 id=\"校验数字的表达式\"><a href=\"#校验数字的表达式\" class=\"headerlink\" title=\"校验数字的表达式\"></a>校验数字的表达式</h4><ol>\n<li>数字:<code>(-?\\d*)(\\.\\d+)?</code></li>\n<li>带1-2位小数的正数或负数:<code>^(\\-)?\\d+(\\.\\d{1,2})?$</code></li>\n<li>非零的正整数:<code>^[1-9]\\d*$</code> 或 <code>^([1-9][0-9]*){1,3}$</code> 或 <code>^\\+?[1-9][0-9]*$</code></li>\n</ol>\n<h4 id=\"校验字符的表达式\"><a href=\"#校验字符的表达式\" class=\"headerlink\" title=\"校验字符的表达式\"></a>校验字符的表达式</h4><ol>\n<li>汉字:<code>^[\\u4e00-\\u9fa5]{0,}$</code></li>\n<li>英文和数字:<code>^[A-Za-z0-9]+$</code> 或 <code>^[A-Za-z0-9]{4,40}$</code></li>\n<li>长度为3-20的所有字符:<code>^.{3,20}$</code></li>\n<li>中文、英文、数字但不包括下划线等符号:<code>^[\\u4E00-\\u9FA5A-Za-z0-9]+$</code> 或 <code>^[\\u4E00-\\u9FA5A-Za-z0-9]{2,20}$</code></li>\n<li>可以输入含有<code>^%&',;=?$\\"</code>等字符:<code>[^%&',;=?$\\x22]+</code></li>\n</ol>\n<h4 id=\"特殊需求表达式\"><a href=\"#特殊需求表达式\" class=\"headerlink\" title=\"特殊需求表达式\"></a>特殊需求表达式</h4><ol>\n<li>Email地址:<code>^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$</code></li>\n<li>域名:<code>[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?</code></li>\n<li>InternetURL:<code>(h|H)(r|R)(e|E)(f|F) *= *('|")?(\\w|\\\\|\\/|\\.)+('|"| *|>)?</code></li>\n<li>手机号码:<code>^1[34578]\\d{9}$</code> 或 <code>^1(3|4|5|7|8)\\d{9}$</code> 或 <code>^1[0-9]{10}$</code></li>\n<li>5 电话号码:<code>^(\\(\\d{3,4}-)|\\d{3.4}-)?\\d{7,8}$</code> </li>\n<li>身份证号(15位、18位数字):<code>(^\\d{15}$)|(^\\d{17}([0-9]|X)$)</code></li>\n<li>日期格式:<code>^\\d{4}-\\d{1,2}-\\d{1,2}</code></li>\n<li>中文字符的正则表达式:<code>[\\u4e00-\\u9fa5]</code></li>\n<li>空白行的正则表达式:<code>\\n\\s*\\r</code> (可以用来删除空白行)</li>\n<li>首尾空白字符的正则表达式:<code>^\\s*|\\s*$或(^\\s*)|(\\s*$)</code> (可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式)</li>\n<li>IP地址:<code>\\d+\\.\\d+\\.\\d+\\.\\d+</code> (提取IP地址时有用)</li>\n<li>中国邮政编码:<code>[1-9]\\d{5}(?!\\d)</code> (中国邮政编码为6位数字)</li>\n<li>腾讯QQ号:<code>[1-9][0-9]{4,}</code> (腾讯QQ号从10000开始)</li>\n</ol>\n","excerpt":"","more":"<h3 id=\"基础\"><a href=\"#基础\" class=\"headerlink\" title=\"基础\"></a>基础</h3><h4 id=\"正则表达式匹配\"><a href=\"#正则表达式匹配\" class=\"headerlink\" title=\"正则表达式匹配\"></a>正则表达式匹配</h4><p>  一般来说,正则表达式就是以某种方式来描述字符串。例如,“要找一个数字,他<strong>可能</strong>有一个负号在最前面”,则用<code>-?</code>表示。<br>  在正则表达式中,<code>\\d</code>表示一位数字。但在Java中,需要用<code>\\\\</code>表示后面的字符有特殊的意义,所以一位数字应该用<code>\\\\d</code>表示。<br>  要表示“一个或多个之前的表达式”,应该使用<code>+</code>。例如,“表示一个负号,后面跟着一位或多位数字”,表达式为:<br>  <code>-?\\\\d+</code></p>\n<p>  检查一个String是否匹配如上所诉的正则表达式<br><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">IntegerMatch</span></span>{</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">main</span><span class=\"params\">(String[] args)</span></span>{</div><div class=\"line\"> System.out.println(<span class=\"string\">\"-1234\"</span>.matches(<span class=\"string\">\"-?\\\\d+\"</span>));<span class=\"comment\">//true</span></div><div class=\"line\"> System.out.println(<span class=\"string\">\"1234\"</span>.matches(<span class=\"string\">\"-?\\\\d+\"</span>));<span class=\"comment\">//true</span></div><div class=\"line\"> System.out.println(<span class=\"string\">\"+1234\"</span>.matches(<span class=\"string\">\"-?\\\\d+\"</span>));<span class=\"comment\">//false</span></div><div class=\"line\"> System.out.println(<span class=\"string\">\"+1234\"</span>.matches(<span class=\"string\">\"(-|\\\\+)?\\\\d+\"</span>));<span class=\"comment\">//true</span></div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure></p>\n<p>前面两个字符串满足对应的正则表达式,匹配成功。第三个字符串开头<code>+</code>,它也是一个合法的字符,但对应的正则表达式不匹配。正则表达式应该描述为“可能以一个加号或减号开头”。在正则表达中,括号<code>()</code>具有分组的效果,而竖线<code>|</code>则表示“或”操作,表达式为:<br>  <code>(-|\\\\+)?\\\\d+</code><br>这个正则表达式表示“字符串的起始字符<strong>可能</strong>是一个<code>-</code>或<code>+</code>,或者二者皆没有(因为后面跟着<code>?</code>修饰符),另外字符<code>+</code>在正则表达式中有特殊意义,所以需要用<code>\\\\</code>转义”。</p>\n<h4 id=\"Java的split和replace方法\"><a href=\"#Java的split和replace方法\" class=\"headerlink\" title=\"Java的split和replace方法\"></a>Java的split和replace方法</h4><ul>\n<li><code>split()</code>方法,旨在将字符串从正则表达式匹配的地方切开<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> class <span class=\"title\">Splitting</span><span class=\"params\">()</span></span>{</div><div class=\"line\"></div><div class=\"line\"> <span class=\"keyword\">public</span> <span class=\"keyword\">static</span> String knights = <span class=\"string\">\"Then, hello world !\"</span>;</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">Splitting</span><span class=\"params\">(String regex)</span></span>{</div><div class=\"line\"> System.out.println(Arrays.toString(knights.split(regex)));</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">main</span><span class=\"params\">(String[] args)</span></span>{</div><div class=\"line\"> Splitting(<span class=\"string\">\" \"</span>);<span class=\"comment\">//[Then,,hello,world,!]</span></div><div class=\"line\"> Splitting(<span class=\"string\">\"\\\\W+\"</span>);<span class=\"comment\">//[Then, hello, world]</span></div><div class=\"line\"> Splitting(<span class=\"string\">\"n\\\\W+\"</span>);<span class=\"comment\">//[The,hello,world!]</span></div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>第二个和第三个表达式都用到了<code>\\W</code>,它的意思是“非单词字符”(如果<code>W</code>小写,<code>\\w</code>,则表示“一个单词字符”)</p>\n<ul>\n<li><code>replace()</code>方法,旨在替换匹配正则表达式的子字符串<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> class <span class=\"title\">Replacing</span><span class=\"params\">()</span></span>{</div><div class=\"line\"></div><div class=\"line\"> <span class=\"keyword\">static</span> String s = Splitting.knights;</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">replaceFirsting</span><span class=\"params\">(String regex, String str)</span></span>{</div><div class=\"line\"> System.out.println(s.replaceAll(regex, str));</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">replaceAlling</span><span class=\"params\">(String regex, String str)</span></span>{</div><div class=\"line\"> System.out.println(s.replaceAll(regex, str));</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">main</span><span class=\"params\">(String[] args)</span></span>{</div><div class=\"line\"> repaceFirsting(<span class=\"string\">\"o\\\\w+\"</span>,<span class=\"string\">\"boy\"</span>);<span class=\"comment\">//Then, hello wboy !</span></div><div class=\"line\"> repaceAlling(<span class=\"string\">\"en|lo|ld\"</span>,<span class=\"string\">\"boy\"</span>);<span class=\"comment\">//Thboy, helboy worboy !</span></div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>第二个表达式用分隔符<code>|</code>,表示“或”。</p>\n<h3 id=\"创建\"><a href=\"#创建\" class=\"headerlink\" title=\"创建\"></a>创建</h3><p>正则表达式的完整构造子列表</p>\n<ul>\n<li>常用字符</li>\n</ul>\n<table>\n<thead>\n<tr>\n<th>表达式</th>\n<th>字符</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>B</td>\n<td>指定字符</td>\n</tr>\n<tr>\n<td>\\xhh</td>\n<td>十六进制值为0xhh</td>\n</tr>\n<tr>\n<td>\\xhhhhh</td>\n<td>十六进制表示为0xhhhh的Unicode字符</td>\n</tr>\n<tr>\n<td>\\t</td>\n<td>制表符Tab</td>\n</tr>\n<tr>\n<td>\\n</td>\n<td>换行符</td>\n</tr>\n<tr>\n<td>\\r</td>\n<td>回车</td>\n</tr>\n<tr>\n<td>\\f</td>\n<td>换页</td>\n</tr>\n<tr>\n<td>\\e</td>\n<td>转义(Esc)</td>\n</tr>\n</tbody>\n</table>\n<ul>\n<li>常用字符类</li>\n</ul>\n<table>\n<thead>\n<tr>\n<th>表达式</th>\n<th>字符</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>.</td>\n<td>任意字符</td>\n</tr>\n<tr>\n<td>[abc]</td>\n<td>包含a,b,c的任何字符(同 ‘a或b或c’)</td>\n</tr>\n<tr>\n<td>[^abc]</td>\n<td>除a,b,c之外的任何字符</td>\n</tr>\n<tr>\n<td>[a-zA-Z]</td>\n<td>从a~z和A~Z的任何字符(范围)</td>\n</tr>\n<tr>\n<td>abc[hij]</td>\n<td>同 ‘a或b或c或h或i或j’(合并</td>\n</tr>\n<tr>\n<td>a-z&&[hij]</td>\n<td>任意h,i,j(交集)</td>\n</tr>\n<tr>\n<td>\\s</td>\n<td>空白符(空格,tab,换行,回车,换页)</td>\n</tr>\n<tr>\n<td>\\S</td>\n<td>非空白符,(同[^\\s])</td>\n</tr>\n<tr>\n<td>\\d</td>\n<td>数字0~9</td>\n</tr>\n<tr>\n<td>\\D</td>\n<td>非数字,(同[^0-9])</td>\n</tr>\n<tr>\n<td>\\w</td>\n<td>词字符[a-zA-Z0-9]</td>\n</tr>\n<tr>\n<td>\\W</td>\n<td>非词字符,(同[^\\w])</td>\n</tr>\n</tbody>\n</table>\n<h3 id=\"常用\"><a href=\"#常用\" class=\"headerlink\" title=\"常用\"></a>常用</h3><h4 id=\"校验数字的表达式\"><a href=\"#校验数字的表达式\" class=\"headerlink\" title=\"校验数字的表达式\"></a>校验数字的表达式</h4><ol>\n<li>数字:<code>(-?\\d*)(\\.\\d+)?</code></li>\n<li>带1-2位小数的正数或负数:<code>^(\\-)?\\d+(\\.\\d{1,2})?$</code></li>\n<li>非零的正整数:<code>^[1-9]\\d*$</code> 或 <code>^([1-9][0-9]*){1,3}$</code> 或 <code>^\\+?[1-9][0-9]*$</code></li>\n</ol>\n<h4 id=\"校验字符的表达式\"><a href=\"#校验字符的表达式\" class=\"headerlink\" title=\"校验字符的表达式\"></a>校验字符的表达式</h4><ol>\n<li>汉字:<code>^[\\u4e00-\\u9fa5]{0,}$</code></li>\n<li>英文和数字:<code>^[A-Za-z0-9]+$</code> 或 <code>^[A-Za-z0-9]{4,40}$</code></li>\n<li>长度为3-20的所有字符:<code>^.{3,20}$</code></li>\n<li>中文、英文、数字但不包括下划线等符号:<code>^[\\u4E00-\\u9FA5A-Za-z0-9]+$</code> 或 <code>^[\\u4E00-\\u9FA5A-Za-z0-9]{2,20}$</code></li>\n<li>可以输入含有<code>^%&',;=?$\\"</code>等字符:<code>[^%&',;=?$\\x22]+</code></li>\n</ol>\n<h4 id=\"特殊需求表达式\"><a href=\"#特殊需求表达式\" class=\"headerlink\" title=\"特殊需求表达式\"></a>特殊需求表达式</h4><ol>\n<li>Email地址:<code>^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$</code></li>\n<li>域名:<code>[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?</code></li>\n<li>InternetURL:<code>(h|H)(r|R)(e|E)(f|F) *= *('|")?(\\w|\\\\|\\/|\\.)+('|"| *|>)?</code></li>\n<li>手机号码:<code>^1[34578]\\d{9}$</code> 或 <code>^1(3|4|5|7|8)\\d{9}$</code> 或 <code>^1[0-9]{10}$</code></li>\n<li>5 电话号码:<code>^(\\(\\d{3,4}-)|\\d{3.4}-)?\\d{7,8}$</code> </li>\n<li>身份证号(15位、18位数字):<code>(^\\d{15}$)|(^\\d{17}([0-9]|X)$)</code></li>\n<li>日期格式:<code>^\\d{4}-\\d{1,2}-\\d{1,2}</code></li>\n<li>中文字符的正则表达式:<code>[\\u4e00-\\u9fa5]</code></li>\n<li>空白行的正则表达式:<code>\\n\\s*\\r</code> (可以用来删除空白行)</li>\n<li>首尾空白字符的正则表达式:<code>^\\s*|\\s*$或(^\\s*)|(\\s*$)</code> (可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式)</li>\n<li>IP地址:<code>\\d+\\.\\d+\\.\\d+\\.\\d+</code> (提取IP地址时有用)</li>\n<li>中国邮政编码:<code>[1-9]\\d{5}(?!\\d)</code> (中国邮政编码为6位数字)</li>\n<li>腾讯QQ号:<code>[1-9][0-9]{4,}</code> (腾讯QQ号从10000开始)</li>\n</ol>\n"},{"title":"SQL分组查询","date":"2016-09-03T10:25:50.000Z","_content":"\n### group by\n\n- 什么是分组查询?\n使用`group by`子句将表中的数据分成若干组,再对分组之后的数据做统计计算,一般使用`聚集函数`才使用`group by`\n\n- 聚集函数:`sum`,`avg`,`count`,`min`,`max`\n- 分组查询的格式\n```SQL\nselect\n <selectList>,聚集函数\nfrom\n t_name\nwhere\n 条件\ngroup by\n <selectList>\n```\n\n- 注意\n`group by` 后面的列名的值要有重复性分组才有意义\n\n### having\n\n- 使用`having`子句,对分组之后的结果作筛选\n\n```SQL\nselect\n <selectList>,聚集函数\nfrom\n t_name\nwhere\n 条件\ngroup by\n <selectList>\nhaving\n 组函数\n```\n\n- 注意\n不在`where`子句中使用`组函数`;\n应该在`having`子句中使用`组函数`\n","source":"_posts/SQL分组查询.md","raw":"---\ntitle: SQL分组查询\ndate: 2016-09-03 18:25:50\ncategories: 数据库 \ntags: [SQL]\n---\n\n### group by\n\n- 什么是分组查询?\n使用`group by`子句将表中的数据分成若干组,再对分组之后的数据做统计计算,一般使用`聚集函数`才使用`group by`\n\n- 聚集函数:`sum`,`avg`,`count`,`min`,`max`\n- 分组查询的格式\n```SQL\nselect\n <selectList>,聚集函数\nfrom\n t_name\nwhere\n 条件\ngroup by\n <selectList>\n```\n\n- 注意\n`group by` 后面的列名的值要有重复性分组才有意义\n\n### having\n\n- 使用`having`子句,对分组之后的结果作筛选\n\n```SQL\nselect\n <selectList>,聚集函数\nfrom\n t_name\nwhere\n 条件\ngroup by\n <selectList>\nhaving\n 组函数\n```\n\n- 注意\n不在`where`子句中使用`组函数`;\n应该在`having`子句中使用`组函数`\n","slug":"SQL分组查询","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaidv00083sas4wh40lk4","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"group-by\"><a href=\"#group-by\" class=\"headerlink\" title=\"group by\"></a>group by</h3><ul>\n<li><p>什么是分组查询?<br>使用<code>group by</code>子句将表中的数据分成若干组,再对分组之后的数据做统计计算,一般使用<code>聚集函数</code>才使用<code>group by</code></p>\n</li>\n<li><p>聚集函数:<code>sum</code>,<code>avg</code>,<code>count</code>,<code>min</code>,<code>max</code></p>\n</li>\n<li><p>分组查询的格式</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> <selectList>,聚集函数</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> t_name</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> 条件</div><div class=\"line\"><span class=\"keyword\">group</span> <span class=\"keyword\">by</span></div><div class=\"line\"> <selectList></div></pre></td></tr></table></figure>\n</li>\n<li><p>注意<br><code>group by</code> 后面的列名的值要有重复性分组才有意义</p>\n</li>\n</ul>\n<h3 id=\"having\"><a href=\"#having\" class=\"headerlink\" title=\"having\"></a>having</h3><ul>\n<li>使用<code>having</code>子句,对分组之后的结果作筛选</li>\n</ul>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> <selectList>,聚集函数</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> t_name</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> 条件</div><div class=\"line\"><span class=\"keyword\">group</span> <span class=\"keyword\">by</span></div><div class=\"line\"> <selectList></div><div class=\"line\"><span class=\"keyword\">having</span></div><div class=\"line\"> 组函数</div></pre></td></tr></table></figure>\n<ul>\n<li>注意<br>不在<code>where</code>子句中使用<code>组函数</code>;<br>应该在<code>having</code>子句中使用<code>组函数</code></li>\n</ul>\n","excerpt":"","more":"<h3 id=\"group-by\"><a href=\"#group-by\" class=\"headerlink\" title=\"group by\"></a>group by</h3><ul>\n<li><p>什么是分组查询?<br>使用<code>group by</code>子句将表中的数据分成若干组,再对分组之后的数据做统计计算,一般使用<code>聚集函数</code>才使用<code>group by</code></p>\n</li>\n<li><p>聚集函数:<code>sum</code>,<code>avg</code>,<code>count</code>,<code>min</code>,<code>max</code></p>\n</li>\n<li><p>分组查询的格式</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> <selectList>,聚集函数</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> t_name</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> 条件</div><div class=\"line\"><span class=\"keyword\">group</span> <span class=\"keyword\">by</span></div><div class=\"line\"> <selectList></div></pre></td></tr></table></figure>\n</li>\n<li><p>注意<br><code>group by</code> 后面的列名的值要有重复性分组才有意义</p>\n</li>\n</ul>\n<h3 id=\"having\"><a href=\"#having\" class=\"headerlink\" title=\"having\"></a>having</h3><ul>\n<li>使用<code>having</code>子句,对分组之后的结果作筛选</li>\n</ul>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> <selectList>,聚集函数</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> t_name</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> 条件</div><div class=\"line\"><span class=\"keyword\">group</span> <span class=\"keyword\">by</span></div><div class=\"line\"> <selectList></div><div class=\"line\"><span class=\"keyword\">having</span></div><div class=\"line\"> 组函数</div></pre></td></tr></table></figure>\n<ul>\n<li>注意<br>不在<code>where</code>子句中使用<code>组函数</code>;<br>应该在<code>having</code>子句中使用<code>组函数</code></li>\n</ul>\n"},{"title":"SQL子查询基于MySQL","date":"2016-09-03T13:42:42.000Z","_content":"\n### 什么是子查询\n\n子查询也叫嵌套查询,一个查询语句嵌套在另一个查询语句中,内层查询的结果可以作为外层查询条件,或者可以看成临时表。一般的,嵌套在`where` 或者 `from`子句中。\n\n多表连接查询过程:\n- 两张表做笛卡尔积;\n- 筛选匹配条件的数据记录\n- 若笛卡尔积记录数比较大,可能造成服务器崩溃\n\n\nExample Tables:商品表和商品分类表\n\n```SQL\n\nmysql> select * from product;\n+----+----------------+--------+-----------+----------+-------+--------+-----------+\n| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |\n+----+----------------+--------+-----------+----------+-------+--------+-----------+\n| 1 | 罗技M90 | 3 | 90 | 罗技 | 罗技 | 0.5 | 35 |\n| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |\n| 3 | 罗技M115 | 3 | 99 | 罗技 | 罗技 | 0.6 | 38 |\n| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |\n| 5 | 罗技木星轨迹球 | 3 | 182 | 罗技 | 罗技 | 0.8 | 80 |\n| 6 | 罗技火星轨迹球 | 3 | 349 | 罗技 | 罗技 | 0.87 | 290 |\n| 7 | 罗技G9X | 3 | 680 | 罗技 | 罗技 | 0.7 | 470 |\n| 8 | 罗技M215 | 2 | 89 | 罗技 | 罗技 | 0.79 | 30 |\n| 9 | 罗技M305 | 2 | 119 | 罗技 | 罗技 | 0.82 | 48 |\n| 10 | 罗技M310 | 2 | 135 | 罗技 | 罗技 | 0.92 | 69.8 |\n| 11 | 罗技M505 | 2 | 148 | 罗技 | 罗技 | 0.92 | 72 |\n| 12 | 罗技M555 | 2 | 275 | 罗技 | 罗技 | 0.88 | 140 |\n| 13 | 罗技M905 | 2 | 458 | 罗技 | 罗技 | 0.88 | 270 |\n| 14 | 罗技MX1100 | 2 | 550 | 罗技 | 罗技 | 0.76 | 300 |\n| 15 | 罗技M950 | 2 | 678 | 罗技 | 罗技 | 0.78 | 320 |\n| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |\n| 17 | 罗技G1 | 4 | 155 | 罗技 | 罗技 | 0.8 | 49 |\n| 18 | 罗技G3 | 4 | 229 | 罗技 | 罗技 | 0.77 | 96 |\n| 19 | 罗技G500 | 4 | 399 | 罗技 | 罗技 | 0.88 | 130 |\n| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |\n+----+----------------+--------+-----------+----------+-------+--------+-----------+\n```\n\n```SQL\nmysql> select * from productdir;\n+----+----------+-----------+\n| id | dirName | parent_id |\n+----+----------+-----------+\n| 1 | 鼠标 | NULL |\n| 2 | 无线鼠标 | 1 |\n| 3 | 有线鼠标 | 1 |\n| 4 | 游戏鼠标 | 1 |\n+----+----------+-----------+\n```\n\n### 子查询之单行单列查询\n\n子查询的结果(临时表),返回的是只有一行,且只有一列的数据,提供作外表查询的条件\n- 需求:查询零售价比‘罗技G90X’更高的商品信息。\n\n- sql语句\n```SQL\nselect\n *\nfrom\n product\nwhere\n salePrice > (\n select\n salePrice\n from\n product\n where\n productName = '罗技G9X'\n );\n```\n- 查询结果\n```SQL\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |\n| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n```\n\n### 子查询之单行多列查询\n\n子查询的结果(临时表),返回的是只有一行,但是有多列的数据,提供作外表查询的条件\n- 需求:查询分类编号和折扣与‘罗技M100’相同的的商品信息。\n\n- sql语句\n```SQL\nselect\n p.*\nfrom\n product p\nwhere\n (p.dir_id,p.cutoff)=(\n select\n p.dir_id,p.cutoff\n from\n product p\n where\n p.productName = '罗技M100'\n );\n```\n\n- 查询结果\n```SQL\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |\n| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n```\n\n### 子查询之多行多列查询\n\n- 需求:查询各商品的分类的分类编号,分类名称,商品数量,平均价格\n\n- sql语句\n```SQL\nselect\n pd.id,pd.dirName,temp.CountNum,temp.avgPrice\nfrom\n productdir pd\njoin\n(\n select\n p.dir_id tId, count(p.id) countNum, avg(p.salePrice) avgPrice\n from\n product p\n group by\n p.dir_id\n)\n temp\non\n pd.id = temp.tId;\n```\n\n- 查询结果\n```SQL\n+----+----------+----------+------------+\n| id | dirName | CountNum | avgPrice |\n+----+----------+----------+------------+\n| 2 | 无线鼠标 | 9 | 416.777778 |\n| 3 | 有线鼠标 | 7 | 218.428571 |\n| 4 | 游戏鼠标 | 4 | 370.5 |\n+----+----------+----------+------------+\n```\n","source":"_posts/SQL子查询.md","raw":"---\ntitle: SQL子查询基于MySQL\ndate: 2016-09-03 21:42:42\ncategories: 数据库 \ntags: [SQL]\n---\n\n### 什么是子查询\n\n子查询也叫嵌套查询,一个查询语句嵌套在另一个查询语句中,内层查询的结果可以作为外层查询条件,或者可以看成临时表。一般的,嵌套在`where` 或者 `from`子句中。\n\n多表连接查询过程:\n- 两张表做笛卡尔积;\n- 筛选匹配条件的数据记录\n- 若笛卡尔积记录数比较大,可能造成服务器崩溃\n\n\nExample Tables:商品表和商品分类表\n\n```SQL\n\nmysql> select * from product;\n+----+----------------+--------+-----------+----------+-------+--------+-----------+\n| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |\n+----+----------------+--------+-----------+----------+-------+--------+-----------+\n| 1 | 罗技M90 | 3 | 90 | 罗技 | 罗技 | 0.5 | 35 |\n| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |\n| 3 | 罗技M115 | 3 | 99 | 罗技 | 罗技 | 0.6 | 38 |\n| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |\n| 5 | 罗技木星轨迹球 | 3 | 182 | 罗技 | 罗技 | 0.8 | 80 |\n| 6 | 罗技火星轨迹球 | 3 | 349 | 罗技 | 罗技 | 0.87 | 290 |\n| 7 | 罗技G9X | 3 | 680 | 罗技 | 罗技 | 0.7 | 470 |\n| 8 | 罗技M215 | 2 | 89 | 罗技 | 罗技 | 0.79 | 30 |\n| 9 | 罗技M305 | 2 | 119 | 罗技 | 罗技 | 0.82 | 48 |\n| 10 | 罗技M310 | 2 | 135 | 罗技 | 罗技 | 0.92 | 69.8 |\n| 11 | 罗技M505 | 2 | 148 | 罗技 | 罗技 | 0.92 | 72 |\n| 12 | 罗技M555 | 2 | 275 | 罗技 | 罗技 | 0.88 | 140 |\n| 13 | 罗技M905 | 2 | 458 | 罗技 | 罗技 | 0.88 | 270 |\n| 14 | 罗技MX1100 | 2 | 550 | 罗技 | 罗技 | 0.76 | 300 |\n| 15 | 罗技M950 | 2 | 678 | 罗技 | 罗技 | 0.78 | 320 |\n| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |\n| 17 | 罗技G1 | 4 | 155 | 罗技 | 罗技 | 0.8 | 49 |\n| 18 | 罗技G3 | 4 | 229 | 罗技 | 罗技 | 0.77 | 96 |\n| 19 | 罗技G500 | 4 | 399 | 罗技 | 罗技 | 0.88 | 130 |\n| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |\n+----+----------------+--------+-----------+----------+-------+--------+-----------+\n```\n\n```SQL\nmysql> select * from productdir;\n+----+----------+-----------+\n| id | dirName | parent_id |\n+----+----------+-----------+\n| 1 | 鼠标 | NULL |\n| 2 | 无线鼠标 | 1 |\n| 3 | 有线鼠标 | 1 |\n| 4 | 游戏鼠标 | 1 |\n+----+----------+-----------+\n```\n\n### 子查询之单行单列查询\n\n子查询的结果(临时表),返回的是只有一行,且只有一列的数据,提供作外表查询的条件\n- 需求:查询零售价比‘罗技G90X’更高的商品信息。\n\n- sql语句\n```SQL\nselect\n *\nfrom\n product\nwhere\n salePrice > (\n select\n salePrice\n from\n product\n where\n productName = '罗技G9X'\n );\n```\n- 查询结果\n```SQL\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |\n| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n```\n\n### 子查询之单行多列查询\n\n子查询的结果(临时表),返回的是只有一行,但是有多列的数据,提供作外表查询的条件\n- 需求:查询分类编号和折扣与‘罗技M100’相同的的商品信息。\n\n- sql语句\n```SQL\nselect\n p.*\nfrom\n product p\nwhere\n (p.dir_id,p.cutoff)=(\n select\n p.dir_id,p.cutoff\n from\n product p\n where\n p.productName = '罗技M100'\n );\n```\n\n- 查询结果\n```SQL\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |\n| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |\n+----+-------------+--------+-----------+----------+-------+--------+-----------+\n```\n\n### 子查询之多行多列查询\n\n- 需求:查询各商品的分类的分类编号,分类名称,商品数量,平均价格\n\n- sql语句\n```SQL\nselect\n pd.id,pd.dirName,temp.CountNum,temp.avgPrice\nfrom\n productdir pd\njoin\n(\n select\n p.dir_id tId, count(p.id) countNum, avg(p.salePrice) avgPrice\n from\n product p\n group by\n p.dir_id\n)\n temp\non\n pd.id = temp.tId;\n```\n\n- 查询结果\n```SQL\n+----+----------+----------+------------+\n| id | dirName | CountNum | avgPrice |\n+----+----------+----------+------------+\n| 2 | 无线鼠标 | 9 | 416.777778 |\n| 3 | 有线鼠标 | 7 | 218.428571 |\n| 4 | 游戏鼠标 | 4 | 370.5 |\n+----+----------+----------+------------+\n```\n","slug":"SQL子查询","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaidz000a3sas8hp10e1y","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"什么是子查询\"><a href=\"#什么是子查询\" class=\"headerlink\" title=\"什么是子查询\"></a>什么是子查询</h3><p>子查询也叫嵌套查询,一个查询语句嵌套在另一个查询语句中,内层查询的结果可以作为外层查询条件,或者可以看成临时表。一般的,嵌套在<code>where</code> 或者 <code>from</code>子句中。</p>\n<p>多表连接查询过程:</p>\n<ul>\n<li>两张表做笛卡尔积;</li>\n<li>筛选匹配条件的数据记录</li>\n<li>若笛卡尔积记录数比较大,可能造成服务器崩溃</li>\n</ul>\n<p>Example Tables:商品表和商品分类表</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div></pre></td><td class=\"code\"><pre><div class=\"line\"></div><div class=\"line\">mysql> select * from product;</div><div class=\"line\">+----+----------------+--------+-----------+----------+-------+--------+-----------+</div><div class=\"line\">| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |</div><div class=\"line\">+----+----------------+--------+-----------+----------+-------+--------+-----------+</div><div class=\"line\">| 1 | 罗技M90 | 3 | 90 | 罗技 | 罗技 | 0.5 | 35 |</div><div class=\"line\">| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |</div><div class=\"line\">| 3 | 罗技M115 | 3 | 99 | 罗技 | 罗技 | 0.6 | 38 |</div><div class=\"line\">| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |</div><div class=\"line\">| 5 | 罗技木星轨迹球 | 3 | 182 | 罗技 | 罗技 | 0.8 | 80 |</div><div class=\"line\">| 6 | 罗技火星轨迹球 | 3 | 349 | 罗技 | 罗技 | 0.87 | 290 |</div><div class=\"line\">| 7 | 罗技G9X | 3 | 680 | 罗技 | 罗技 | 0.7 | 470 |</div><div class=\"line\">| 8 | 罗技M215 | 2 | 89 | 罗技 | 罗技 | 0.79 | 30 |</div><div class=\"line\">| 9 | 罗技M305 | 2 | 119 | 罗技 | 罗技 | 0.82 | 48 |</div><div class=\"line\">| 10 | 罗技M310 | 2 | 135 | 罗技 | 罗技 | 0.92 | 69.8 |</div><div class=\"line\">| 11 | 罗技M505 | 2 | 148 | 罗技 | 罗技 | 0.92 | 72 |</div><div class=\"line\">| 12 | 罗技M555 | 2 | 275 | 罗技 | 罗技 | 0.88 | 140 |</div><div class=\"line\">| 13 | 罗技M905 | 2 | 458 | 罗技 | 罗技 | 0.88 | 270 |</div><div class=\"line\">| 14 | 罗技MX1100 | 2 | 550 | 罗技 | 罗技 | 0.76 | 300 |</div><div class=\"line\">| 15 | 罗技M950 | 2 | 678 | 罗技 | 罗技 | 0.78 | 320 |</div><div class=\"line\">| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |</div><div class=\"line\">| 17 | 罗技G1 | 4 | 155 | 罗技 | 罗技 | 0.8 | 49 |</div><div class=\"line\">| 18 | 罗技G3 | 4 | 229 | 罗技 | 罗技 | 0.77 | 96 |</div><div class=\"line\">| 19 | 罗技G500 | 4 | 399 | 罗技 | 罗技 | 0.88 | 130 |</div><div class=\"line\">| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |</div><div class=\"line\">+----+----------------+--------+-----------+----------+-------+--------+-----------+</div></pre></td></tr></table></figure>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\">mysql> select * from productdir;</div><div class=\"line\">+----+----------+-----------+</div><div class=\"line\">| id | dirName | parent_id |</div><div class=\"line\">+----+----------+-----------+</div><div class=\"line\">| 1 | 鼠标 | NULL |</div><div class=\"line\">| 2 | 无线鼠标 | 1 |</div><div class=\"line\">| 3 | 有线鼠标 | 1 |</div><div class=\"line\">| 4 | 游戏鼠标 | 1 |</div><div class=\"line\">+----+----------+-----------+</div></pre></td></tr></table></figure>\n<h3 id=\"子查询之单行单列查询\"><a href=\"#子查询之单行单列查询\" class=\"headerlink\" title=\"子查询之单行单列查询\"></a>子查询之单行单列查询</h3><p>子查询的结果(临时表),返回的是只有一行,且只有一列的数据,提供作外表查询的条件</p>\n<ul>\n<li><p>需求:查询零售价比‘罗技G90X’更高的商品信息。</p>\n</li>\n<li><p>sql语句</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> *</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> product</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> salePrice > (</div><div class=\"line\"> <span class=\"keyword\">select</span></div><div class=\"line\"> salePrice</div><div class=\"line\"> <span class=\"keyword\">from</span></div><div class=\"line\"> product</div><div class=\"line\"> <span class=\"keyword\">where</span></div><div class=\"line\"> productName = <span class=\"string\">'罗技G9X'</span></div><div class=\"line\"> );</div></pre></td></tr></table></figure>\n</li>\n<li><p>查询结果</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div></pre></td><td class=\"code\"><pre><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |</div><div class=\"line\">| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"子查询之单行多列查询\"><a href=\"#子查询之单行多列查询\" class=\"headerlink\" title=\"子查询之单行多列查询\"></a>子查询之单行多列查询</h3><p>子查询的结果(临时表),返回的是只有一行,但是有多列的数据,提供作外表查询的条件</p>\n<ul>\n<li><p>需求:查询分类编号和折扣与‘罗技M100’相同的的商品信息。</p>\n</li>\n<li><p>sql语句</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> p.*</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> product p</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> (p.dir_id,p.cutoff)=(</div><div class=\"line\"> <span class=\"keyword\">select</span></div><div class=\"line\"> p.dir_id,p.cutoff</div><div class=\"line\"> <span class=\"keyword\">from</span></div><div class=\"line\"> product p</div><div class=\"line\"> <span class=\"keyword\">where</span></div><div class=\"line\"> p.productName = <span class=\"string\">'罗技M100'</span></div><div class=\"line\"> );</div></pre></td></tr></table></figure>\n</li>\n<li><p>查询结果</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div></pre></td><td class=\"code\"><pre><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |</div><div class=\"line\">| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"子查询之多行多列查询\"><a href=\"#子查询之多行多列查询\" class=\"headerlink\" title=\"子查询之多行多列查询\"></a>子查询之多行多列查询</h3><ul>\n<li><p>需求:查询各商品的分类的分类编号,分类名称,商品数量,平均价格</p>\n</li>\n<li><p>sql语句</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> pd.id,pd.dirName,temp.CountNum,temp.avgPrice</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> productdir pd</div><div class=\"line\"><span class=\"keyword\">join</span></div><div class=\"line\">(</div><div class=\"line\"> <span class=\"keyword\">select</span></div><div class=\"line\"> p.dir_id tId, <span class=\"keyword\">count</span>(p.id) countNum, <span class=\"keyword\">avg</span>(p.salePrice) avgPrice</div><div class=\"line\"> <span class=\"keyword\">from</span></div><div class=\"line\"> product p</div><div class=\"line\"> <span class=\"keyword\">group</span> <span class=\"keyword\">by</span></div><div class=\"line\"> p.dir_id</div><div class=\"line\">)</div><div class=\"line\"> temp</div><div class=\"line\"><span class=\"keyword\">on</span></div><div class=\"line\"> pd.id = temp.tId;</div></pre></td></tr></table></figure>\n</li>\n<li><p>查询结果</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div></pre></td><td class=\"code\"><pre><div class=\"line\">+<span class=\"comment\">----+----------+----------+------------+</span></div><div class=\"line\">| id | dirName | CountNum | avgPrice |</div><div class=\"line\">+<span class=\"comment\">----+----------+----------+------------+</span></div><div class=\"line\">| 2 | 无线鼠标 | 9 | 416.777778 |</div><div class=\"line\">| 3 | 有线鼠标 | 7 | 218.428571 |</div><div class=\"line\">| 4 | 游戏鼠标 | 4 | 370.5 |</div><div class=\"line\">+<span class=\"comment\">----+----------+----------+------------+</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n","excerpt":"","more":"<h3 id=\"什么是子查询\"><a href=\"#什么是子查询\" class=\"headerlink\" title=\"什么是子查询\"></a>什么是子查询</h3><p>子查询也叫嵌套查询,一个查询语句嵌套在另一个查询语句中,内层查询的结果可以作为外层查询条件,或者可以看成临时表。一般的,嵌套在<code>where</code> 或者 <code>from</code>子句中。</p>\n<p>多表连接查询过程:</p>\n<ul>\n<li>两张表做笛卡尔积;</li>\n<li>筛选匹配条件的数据记录</li>\n<li>若笛卡尔积记录数比较大,可能造成服务器崩溃</li>\n</ul>\n<p>Example Tables:商品表和商品分类表</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div></pre></td><td class=\"code\"><pre><div class=\"line\"></div><div class=\"line\">mysql> select * from product;</div><div class=\"line\">+----+----------------+--------+-----------+----------+-------+--------+-----------+</div><div class=\"line\">| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |</div><div class=\"line\">+----+----------------+--------+-----------+----------+-------+--------+-----------+</div><div class=\"line\">| 1 | 罗技M90 | 3 | 90 | 罗技 | 罗技 | 0.5 | 35 |</div><div class=\"line\">| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |</div><div class=\"line\">| 3 | 罗技M115 | 3 | 99 | 罗技 | 罗技 | 0.6 | 38 |</div><div class=\"line\">| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |</div><div class=\"line\">| 5 | 罗技木星轨迹球 | 3 | 182 | 罗技 | 罗技 | 0.8 | 80 |</div><div class=\"line\">| 6 | 罗技火星轨迹球 | 3 | 349 | 罗技 | 罗技 | 0.87 | 290 |</div><div class=\"line\">| 7 | 罗技G9X | 3 | 680 | 罗技 | 罗技 | 0.7 | 470 |</div><div class=\"line\">| 8 | 罗技M215 | 2 | 89 | 罗技 | 罗技 | 0.79 | 30 |</div><div class=\"line\">| 9 | 罗技M305 | 2 | 119 | 罗技 | 罗技 | 0.82 | 48 |</div><div class=\"line\">| 10 | 罗技M310 | 2 | 135 | 罗技 | 罗技 | 0.92 | 69.8 |</div><div class=\"line\">| 11 | 罗技M505 | 2 | 148 | 罗技 | 罗技 | 0.92 | 72 |</div><div class=\"line\">| 12 | 罗技M555 | 2 | 275 | 罗技 | 罗技 | 0.88 | 140 |</div><div class=\"line\">| 13 | 罗技M905 | 2 | 458 | 罗技 | 罗技 | 0.88 | 270 |</div><div class=\"line\">| 14 | 罗技MX1100 | 2 | 550 | 罗技 | 罗技 | 0.76 | 300 |</div><div class=\"line\">| 15 | 罗技M950 | 2 | 678 | 罗技 | 罗技 | 0.78 | 320 |</div><div class=\"line\">| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |</div><div class=\"line\">| 17 | 罗技G1 | 4 | 155 | 罗技 | 罗技 | 0.8 | 49 |</div><div class=\"line\">| 18 | 罗技G3 | 4 | 229 | 罗技 | 罗技 | 0.77 | 96 |</div><div class=\"line\">| 19 | 罗技G500 | 4 | 399 | 罗技 | 罗技 | 0.88 | 130 |</div><div class=\"line\">| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |</div><div class=\"line\">+----+----------------+--------+-----------+----------+-------+--------+-----------+</div></pre></td></tr></table></figure>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\">mysql> select * from productdir;</div><div class=\"line\">+----+----------+-----------+</div><div class=\"line\">| id | dirName | parent_id |</div><div class=\"line\">+----+----------+-----------+</div><div class=\"line\">| 1 | 鼠标 | NULL |</div><div class=\"line\">| 2 | 无线鼠标 | 1 |</div><div class=\"line\">| 3 | 有线鼠标 | 1 |</div><div class=\"line\">| 4 | 游戏鼠标 | 1 |</div><div class=\"line\">+----+----------+-----------+</div></pre></td></tr></table></figure>\n<h3 id=\"子查询之单行单列查询\"><a href=\"#子查询之单行单列查询\" class=\"headerlink\" title=\"子查询之单行单列查询\"></a>子查询之单行单列查询</h3><p>子查询的结果(临时表),返回的是只有一行,且只有一列的数据,提供作外表查询的条件</p>\n<ul>\n<li><p>需求:查询零售价比‘罗技G90X’更高的商品信息。</p>\n</li>\n<li><p>sql语句</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> *</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> product</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> salePrice > (</div><div class=\"line\"> <span class=\"keyword\">select</span></div><div class=\"line\"> salePrice</div><div class=\"line\"> <span class=\"keyword\">from</span></div><div class=\"line\"> product</div><div class=\"line\"> <span class=\"keyword\">where</span></div><div class=\"line\"> productName = <span class=\"string\">'罗技G9X'</span></div><div class=\"line\"> );</div></pre></td></tr></table></figure>\n</li>\n<li><p>查询结果</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div></pre></td><td class=\"code\"><pre><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| 16 | 罗技MX Air | 2 | 1299 | 罗技 | 罗技 | 0.72 | 400 |</div><div class=\"line\">| 20 | 罗技G700 | 4 | 699 | 罗技 | 罗技 | 0.79 | 278 |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"子查询之单行多列查询\"><a href=\"#子查询之单行多列查询\" class=\"headerlink\" title=\"子查询之单行多列查询\"></a>子查询之单行多列查询</h3><p>子查询的结果(临时表),返回的是只有一行,但是有多列的数据,提供作外表查询的条件</p>\n<ul>\n<li><p>需求:查询分类编号和折扣与‘罗技M100’相同的的商品信息。</p>\n</li>\n<li><p>sql语句</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> p.*</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> product p</div><div class=\"line\"><span class=\"keyword\">where</span></div><div class=\"line\"> (p.dir_id,p.cutoff)=(</div><div class=\"line\"> <span class=\"keyword\">select</span></div><div class=\"line\"> p.dir_id,p.cutoff</div><div class=\"line\"> <span class=\"keyword\">from</span></div><div class=\"line\"> product p</div><div class=\"line\"> <span class=\"keyword\">where</span></div><div class=\"line\"> p.productName = <span class=\"string\">'罗技M100'</span></div><div class=\"line\"> );</div></pre></td></tr></table></figure>\n</li>\n<li><p>查询结果</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div></pre></td><td class=\"code\"><pre><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| id | productName | dir_id | salePrice | supplier | brand | cutoff | costPrice |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div><div class=\"line\">| 2 | 罗技M100 | 3 | 49 | 罗技 | 罗技 | 0.9 | 33 |</div><div class=\"line\">| 4 | 罗技M125 | 3 | 80 | 罗技 | 罗技 | 0.9 | 39 |</div><div class=\"line\">+<span class=\"comment\">----+-------------+--------+-----------+----------+-------+--------+-----------+</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"子查询之多行多列查询\"><a href=\"#子查询之多行多列查询\" class=\"headerlink\" title=\"子查询之多行多列查询\"></a>子查询之多行多列查询</h3><ul>\n<li><p>需求:查询各商品的分类的分类编号,分类名称,商品数量,平均价格</p>\n</li>\n<li><p>sql语句</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span></div><div class=\"line\"> pd.id,pd.dirName,temp.CountNum,temp.avgPrice</div><div class=\"line\"><span class=\"keyword\">from</span></div><div class=\"line\"> productdir pd</div><div class=\"line\"><span class=\"keyword\">join</span></div><div class=\"line\">(</div><div class=\"line\"> <span class=\"keyword\">select</span></div><div class=\"line\"> p.dir_id tId, <span class=\"keyword\">count</span>(p.id) countNum, <span class=\"keyword\">avg</span>(p.salePrice) avgPrice</div><div class=\"line\"> <span class=\"keyword\">from</span></div><div class=\"line\"> product p</div><div class=\"line\"> <span class=\"keyword\">group</span> <span class=\"keyword\">by</span></div><div class=\"line\"> p.dir_id</div><div class=\"line\">)</div><div class=\"line\"> temp</div><div class=\"line\"><span class=\"keyword\">on</span></div><div class=\"line\"> pd.id = temp.tId;</div></pre></td></tr></table></figure>\n</li>\n<li><p>查询结果</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div></pre></td><td class=\"code\"><pre><div class=\"line\">+<span class=\"comment\">----+----------+----------+------------+</span></div><div class=\"line\">| id | dirName | CountNum | avgPrice |</div><div class=\"line\">+<span class=\"comment\">----+----------+----------+------------+</span></div><div class=\"line\">| 2 | 无线鼠标 | 9 | 416.777778 |</div><div class=\"line\">| 3 | 有线鼠标 | 7 | 218.428571 |</div><div class=\"line\">| 4 | 游戏鼠标 | 4 | 370.5 |</div><div class=\"line\">+<span class=\"comment\">----+----------+----------+------------+</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n"},{"title":"SQL连接查询语法","date":"2016-09-25T03:35:54.000Z","_content":"\n### SQL查询的基本原理\n\n#### 单表查询\n* 根据WHERE条件过滤表中的记录,形成中间表(这个中间表对用户是不可见的);\n* 然后根据SELECT的选择列选择相应的列进行返回最终结果。\n\n#### 两表连接查询\n* 对两表求积(笛卡尔积)并用ON条件和连接连接类型进行过滤形成中间表;\n* 然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。\n\n#### 多表连接查询\n* 先对第一个和第二个表按照两表连接做查询,然后用查询结果和第三个表做连接查询,以此类推;\n* 直到所有的表都连接上为止,最终形成一个中间的结果表;\n* 然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。\n\n#### 备注 ON 和 WHERE 条件\n\n* ON :是过滤两个链接表笛卡尔积形成中间表的约束条件。\n\n* WHERE :在有ON条件的SELECT语句中是过滤中间表的约束条件。在没有ON的单表查询中,是限制物理表或者中间查询结果返回记录的约束。在两表或多表连接中是限制连接形成最终中间表的返回结果的约束。\n\n* 建议:ON只进行连接操作,WHERE只过滤中间表的记录。\n\n---\n\n### 连接查询要点\n\n连接查询是SQL查询的核心,连接查询的连接类型依据实际需求。如果选择不当,非但不能提高查询效率,反而会带来一些逻辑错误或者性能低下的表现。\n1. <span style=\"color:red;\">查两表关联列相等的数据用内连接。</span>\n2. <span style=\"color:red;\">Col_L是Col_R的子集时用右外连接。</span>\n3. <span style=\"color:red;\">Col_R是Col_L的子集时用左外连接。</span>\n4. <span style=\"color:red;\">Col_L和Col_R彼此有交集但彼此互不为子集时用全补。</span>\n5. <span style=\"color:red;\">求差操作时用联合查询。</span>\n\n---\n\n### SQL的四种连接\n\n#### 内连接(INNER JOIN) \n内联接使用比较运算符(例如:= 、 > 、 <)根据每个表共有的列的值匹配两个表中的行。包括相等联接和自然联接。\n* 隐式内连接:没有[INNER JOIN],形成的中间表为两个表的笛卡尔积\n\n* 显式外连接:一般称为内连接,有[INNER JOIN],形成的中间表为两个表经过ON条件过滤后的笛卡尔积。\n\n\n#### 外连接(OUTER JOIN)\n外联接可以是左向外联接、右向外联接或完整外部联接。\n关键字如下:\n* <span style=\"color:red;\">LEFT JOIN</span> 或 <span style=\"color:red;\">LEFT OUTER JOIN</span> :左向外联接的结果集包括 LEFT OUTER 子句中指定的左表的所有行,而不仅仅是联接列所匹配的行。如果左表的某行在右表中没有匹配行,则在相关联的结果集行中右表的所有选择列表列均为null。\n\n* <span style=\"color:red;\">RIGHT JOIN</span> 或 <span style=\"color:red;\">RIGHT OUTER JOIN</span> :右向外联接是左向外联接的反向联接。将返回右表的所有行。如果右表的某行在左表中没有匹配行,则将为左表返回null。\n\n* <span style=\"color:red;\">FULL JOIN</span> 或 <span style=\"color:red;\">FULL OUTER JOIN</span> :完整外部联接返回左表和右表中的所有行。如果表之间有匹配行,则整个结果集行包含基表的数据值。当某行在另一个表中没有匹配行时,则另一个表的选择列表列包含null。\n\n\n#### 交叉连接(CROSS JOIN)\n交叉联接返回左表中的所有行,左表中的每一行与右表中的所有行组合。交叉联接分显式的和隐式的,均不带ON子句,返回的是两表的乘积,称作笛卡尔积。\n* 隐式的交叉连接,没有CROSS JOIN。\n\n* 显式的交叉连接,没有CROSS JOIN。查询结果同隐式。\n\n#### 联合连接(UNION JOIN)\nOracle、MySQL均不支持,其作用是:找出全外连接和内连接之间差异的所有行。这在数据分析中排错中比较常用。也可以利用数据库的集合操作来实现此功能。这是一种很少见的连接方式。\n\n---\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<span style=\"color:red;\"></span>\n\n\n\n\n\n\n###\n","source":"_posts/SQL连接查询语法.md","raw":"---\ntitle: SQL连接查询语法\ndate: 2016-09-25 11:35:54\ncategories: 数据库 \ntags: [SQL]\n---\n\n### SQL查询的基本原理\n\n#### 单表查询\n* 根据WHERE条件过滤表中的记录,形成中间表(这个中间表对用户是不可见的);\n* 然后根据SELECT的选择列选择相应的列进行返回最终结果。\n\n#### 两表连接查询\n* 对两表求积(笛卡尔积)并用ON条件和连接连接类型进行过滤形成中间表;\n* 然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。\n\n#### 多表连接查询\n* 先对第一个和第二个表按照两表连接做查询,然后用查询结果和第三个表做连接查询,以此类推;\n* 直到所有的表都连接上为止,最终形成一个中间的结果表;\n* 然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。\n\n#### 备注 ON 和 WHERE 条件\n\n* ON :是过滤两个链接表笛卡尔积形成中间表的约束条件。\n\n* WHERE :在有ON条件的SELECT语句中是过滤中间表的约束条件。在没有ON的单表查询中,是限制物理表或者中间查询结果返回记录的约束。在两表或多表连接中是限制连接形成最终中间表的返回结果的约束。\n\n* 建议:ON只进行连接操作,WHERE只过滤中间表的记录。\n\n---\n\n### 连接查询要点\n\n连接查询是SQL查询的核心,连接查询的连接类型依据实际需求。如果选择不当,非但不能提高查询效率,反而会带来一些逻辑错误或者性能低下的表现。\n1. <span style=\"color:red;\">查两表关联列相等的数据用内连接。</span>\n2. <span style=\"color:red;\">Col_L是Col_R的子集时用右外连接。</span>\n3. <span style=\"color:red;\">Col_R是Col_L的子集时用左外连接。</span>\n4. <span style=\"color:red;\">Col_L和Col_R彼此有交集但彼此互不为子集时用全补。</span>\n5. <span style=\"color:red;\">求差操作时用联合查询。</span>\n\n---\n\n### SQL的四种连接\n\n#### 内连接(INNER JOIN) \n内联接使用比较运算符(例如:= 、 > 、 <)根据每个表共有的列的值匹配两个表中的行。包括相等联接和自然联接。\n* 隐式内连接:没有[INNER JOIN],形成的中间表为两个表的笛卡尔积\n\n* 显式外连接:一般称为内连接,有[INNER JOIN],形成的中间表为两个表经过ON条件过滤后的笛卡尔积。\n\n\n#### 外连接(OUTER JOIN)\n外联接可以是左向外联接、右向外联接或完整外部联接。\n关键字如下:\n* <span style=\"color:red;\">LEFT JOIN</span> 或 <span style=\"color:red;\">LEFT OUTER JOIN</span> :左向外联接的结果集包括 LEFT OUTER 子句中指定的左表的所有行,而不仅仅是联接列所匹配的行。如果左表的某行在右表中没有匹配行,则在相关联的结果集行中右表的所有选择列表列均为null。\n\n* <span style=\"color:red;\">RIGHT JOIN</span> 或 <span style=\"color:red;\">RIGHT OUTER JOIN</span> :右向外联接是左向外联接的反向联接。将返回右表的所有行。如果右表的某行在左表中没有匹配行,则将为左表返回null。\n\n* <span style=\"color:red;\">FULL JOIN</span> 或 <span style=\"color:red;\">FULL OUTER JOIN</span> :完整外部联接返回左表和右表中的所有行。如果表之间有匹配行,则整个结果集行包含基表的数据值。当某行在另一个表中没有匹配行时,则另一个表的选择列表列包含null。\n\n\n#### 交叉连接(CROSS JOIN)\n交叉联接返回左表中的所有行,左表中的每一行与右表中的所有行组合。交叉联接分显式的和隐式的,均不带ON子句,返回的是两表的乘积,称作笛卡尔积。\n* 隐式的交叉连接,没有CROSS JOIN。\n\n* 显式的交叉连接,没有CROSS JOIN。查询结果同隐式。\n\n#### 联合连接(UNION JOIN)\nOracle、MySQL均不支持,其作用是:找出全外连接和内连接之间差异的所有行。这在数据分析中排错中比较常用。也可以利用数据库的集合操作来实现此功能。这是一种很少见的连接方式。\n\n---\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<span style=\"color:red;\"></span>\n\n\n\n\n\n\n###\n","slug":"SQL连接查询语法","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaie1000d3sash8y3ncm1","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"SQL查询的基本原理\"><a href=\"#SQL查询的基本原理\" class=\"headerlink\" title=\"SQL查询的基本原理\"></a>SQL查询的基本原理</h3><h4 id=\"单表查询\"><a href=\"#单表查询\" class=\"headerlink\" title=\"单表查询\"></a>单表查询</h4><ul>\n<li>根据WHERE条件过滤表中的记录,形成中间表(这个中间表对用户是不可见的);</li>\n<li>然后根据SELECT的选择列选择相应的列进行返回最终结果。</li>\n</ul>\n<h4 id=\"两表连接查询\"><a href=\"#两表连接查询\" class=\"headerlink\" title=\"两表连接查询\"></a>两表连接查询</h4><ul>\n<li>对两表求积(笛卡尔积)并用ON条件和连接连接类型进行过滤形成中间表;</li>\n<li>然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。</li>\n</ul>\n<h4 id=\"多表连接查询\"><a href=\"#多表连接查询\" class=\"headerlink\" title=\"多表连接查询\"></a>多表连接查询</h4><ul>\n<li>先对第一个和第二个表按照两表连接做查询,然后用查询结果和第三个表做连接查询,以此类推;</li>\n<li>直到所有的表都连接上为止,最终形成一个中间的结果表;</li>\n<li>然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。</li>\n</ul>\n<h4 id=\"备注-ON-和-WHERE-条件\"><a href=\"#备注-ON-和-WHERE-条件\" class=\"headerlink\" title=\"备注 ON 和 WHERE 条件\"></a>备注 ON 和 WHERE 条件</h4><ul>\n<li><p>ON :是过滤两个链接表笛卡尔积形成中间表的约束条件。</p>\n</li>\n<li><p>WHERE :在有ON条件的SELECT语句中是过滤中间表的约束条件。在没有ON的单表查询中,是限制物理表或者中间查询结果返回记录的约束。在两表或多表连接中是限制连接形成最终中间表的返回结果的约束。</p>\n</li>\n<li><p>建议:ON只进行连接操作,WHERE只过滤中间表的记录。</p>\n</li>\n</ul>\n<hr>\n<h3 id=\"连接查询要点\"><a href=\"#连接查询要点\" class=\"headerlink\" title=\"连接查询要点\"></a>连接查询要点</h3><p>连接查询是SQL查询的核心,连接查询的连接类型依据实际需求。如果选择不当,非但不能提高查询效率,反而会带来一些逻辑错误或者性能低下的表现。</p>\n<ol>\n<li><span style=\"color:red;\">查两表关联列相等的数据用内连接。</span></li>\n<li><span style=\"color:red;\">Col_L是Col_R的子集时用右外连接。</span></li>\n<li><span style=\"color:red;\">Col_R是Col_L的子集时用左外连接。</span></li>\n<li><span style=\"color:red;\">Col_L和Col_R彼此有交集但彼此互不为子集时用全补。</span></li>\n<li><span style=\"color:red;\">求差操作时用联合查询。</span></li>\n</ol>\n<hr>\n<h3 id=\"SQL的四种连接\"><a href=\"#SQL的四种连接\" class=\"headerlink\" title=\"SQL的四种连接\"></a>SQL的四种连接</h3><h4 id=\"内连接(INNER-JOIN)\"><a href=\"#内连接(INNER-JOIN)\" class=\"headerlink\" title=\"内连接(INNER JOIN)\"></a>内连接(INNER JOIN)</h4><p>内联接使用比较运算符(例如:= 、 > 、 <)根据每个表共有的列的值匹配两个表中的行。包括相等联接和自然联接。</p>\n<ul>\n<li><p>隐式内连接:没有[INNER JOIN],形成的中间表为两个表的笛卡尔积</p>\n</li>\n<li><p>显式外连接:一般称为内连接,有[INNER JOIN],形成的中间表为两个表经过ON条件过滤后的笛卡尔积。</p>\n</li>\n</ul>\n<h4 id=\"外连接(OUTER-JOIN)\"><a href=\"#外连接(OUTER-JOIN)\" class=\"headerlink\" title=\"外连接(OUTER JOIN)\"></a>外连接(OUTER JOIN)</h4><p>外联接可以是左向外联接、右向外联接或完整外部联接。<br>关键字如下:</p>\n<ul>\n<li><p><span style=\"color:red;\">LEFT JOIN</span> 或 <span style=\"color:red;\">LEFT OUTER JOIN</span> :左向外联接的结果集包括 LEFT OUTER 子句中指定的左表的所有行,而不仅仅是联接列所匹配的行。如果左表的某行在右表中没有匹配行,则在相关联的结果集行中右表的所有选择列表列均为null。</p>\n</li>\n<li><p><span style=\"color:red;\">RIGHT JOIN</span> 或 <span style=\"color:red;\">RIGHT OUTER JOIN</span> :右向外联接是左向外联接的反向联接。将返回右表的所有行。如果右表的某行在左表中没有匹配行,则将为左表返回null。</p>\n</li>\n<li><p><span style=\"color:red;\">FULL JOIN</span> 或 <span style=\"color:red;\">FULL OUTER JOIN</span> :完整外部联接返回左表和右表中的所有行。如果表之间有匹配行,则整个结果集行包含基表的数据值。当某行在另一个表中没有匹配行时,则另一个表的选择列表列包含null。</p>\n</li>\n</ul>\n<h4 id=\"交叉连接(CROSS-JOIN)\"><a href=\"#交叉连接(CROSS-JOIN)\" class=\"headerlink\" title=\"交叉连接(CROSS JOIN)\"></a>交叉连接(CROSS JOIN)</h4><p>交叉联接返回左表中的所有行,左表中的每一行与右表中的所有行组合。交叉联接分显式的和隐式的,均不带ON子句,返回的是两表的乘积,称作笛卡尔积。</p>\n<ul>\n<li><p>隐式的交叉连接,没有CROSS JOIN。</p>\n</li>\n<li><p>显式的交叉连接,没有CROSS JOIN。查询结果同隐式。</p>\n</li>\n</ul>\n<h4 id=\"联合连接(UNION-JOIN)\"><a href=\"#联合连接(UNION-JOIN)\" class=\"headerlink\" title=\"联合连接(UNION JOIN)\"></a>联合连接(UNION JOIN)</h4><p>Oracle、MySQL均不支持,其作用是:找出全外连接和内连接之间差异的所有行。这在数据分析中排错中比较常用。也可以利用数据库的集合操作来实现此功能。这是一种很少见的连接方式。</p>\n<hr>\n<p><span style=\"color:red;\"></span></p>\n<p>###</p>\n","excerpt":"","more":"<h3 id=\"SQL查询的基本原理\"><a href=\"#SQL查询的基本原理\" class=\"headerlink\" title=\"SQL查询的基本原理\"></a>SQL查询的基本原理</h3><h4 id=\"单表查询\"><a href=\"#单表查询\" class=\"headerlink\" title=\"单表查询\"></a>单表查询</h4><ul>\n<li>根据WHERE条件过滤表中的记录,形成中间表(这个中间表对用户是不可见的);</li>\n<li>然后根据SELECT的选择列选择相应的列进行返回最终结果。</li>\n</ul>\n<h4 id=\"两表连接查询\"><a href=\"#两表连接查询\" class=\"headerlink\" title=\"两表连接查询\"></a>两表连接查询</h4><ul>\n<li>对两表求积(笛卡尔积)并用ON条件和连接连接类型进行过滤形成中间表;</li>\n<li>然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。</li>\n</ul>\n<h4 id=\"多表连接查询\"><a href=\"#多表连接查询\" class=\"headerlink\" title=\"多表连接查询\"></a>多表连接查询</h4><ul>\n<li>先对第一个和第二个表按照两表连接做查询,然后用查询结果和第三个表做连接查询,以此类推;</li>\n<li>直到所有的表都连接上为止,最终形成一个中间的结果表;</li>\n<li>然后根据WHERE条件过滤中间表的记录,并根据SELECT指定的列返回查询结果。</li>\n</ul>\n<h4 id=\"备注-ON-和-WHERE-条件\"><a href=\"#备注-ON-和-WHERE-条件\" class=\"headerlink\" title=\"备注 ON 和 WHERE 条件\"></a>备注 ON 和 WHERE 条件</h4><ul>\n<li><p>ON :是过滤两个链接表笛卡尔积形成中间表的约束条件。</p>\n</li>\n<li><p>WHERE :在有ON条件的SELECT语句中是过滤中间表的约束条件。在没有ON的单表查询中,是限制物理表或者中间查询结果返回记录的约束。在两表或多表连接中是限制连接形成最终中间表的返回结果的约束。</p>\n</li>\n<li><p>建议:ON只进行连接操作,WHERE只过滤中间表的记录。</p>\n</li>\n</ul>\n<hr>\n<h3 id=\"连接查询要点\"><a href=\"#连接查询要点\" class=\"headerlink\" title=\"连接查询要点\"></a>连接查询要点</h3><p>连接查询是SQL查询的核心,连接查询的连接类型依据实际需求。如果选择不当,非但不能提高查询效率,反而会带来一些逻辑错误或者性能低下的表现。</p>\n<ol>\n<li><span style=\"color:red;\">查两表关联列相等的数据用内连接。</span></li>\n<li><span style=\"color:red;\">Col_L是Col_R的子集时用右外连接。</span></li>\n<li><span style=\"color:red;\">Col_R是Col_L的子集时用左外连接。</span></li>\n<li><span style=\"color:red;\">Col_L和Col_R彼此有交集但彼此互不为子集时用全补。</span></li>\n<li><span style=\"color:red;\">求差操作时用联合查询。</span></li>\n</ol>\n<hr>\n<h3 id=\"SQL的四种连接\"><a href=\"#SQL的四种连接\" class=\"headerlink\" title=\"SQL的四种连接\"></a>SQL的四种连接</h3><h4 id=\"内连接(INNER-JOIN)\"><a href=\"#内连接(INNER-JOIN)\" class=\"headerlink\" title=\"内连接(INNER JOIN)\"></a>内连接(INNER JOIN)</h4><p>内联接使用比较运算符(例如:= 、 > 、 <)根据每个表共有的列的值匹配两个表中的行。包括相等联接和自然联接。</p>\n<ul>\n<li><p>隐式内连接:没有[INNER JOIN],形成的中间表为两个表的笛卡尔积</p>\n</li>\n<li><p>显式外连接:一般称为内连接,有[INNER JOIN],形成的中间表为两个表经过ON条件过滤后的笛卡尔积。</p>\n</li>\n</ul>\n<h4 id=\"外连接(OUTER-JOIN)\"><a href=\"#外连接(OUTER-JOIN)\" class=\"headerlink\" title=\"外连接(OUTER JOIN)\"></a>外连接(OUTER JOIN)</h4><p>外联接可以是左向外联接、右向外联接或完整外部联接。<br>关键字如下:</p>\n<ul>\n<li><p><span style=\"color:red;\">LEFT JOIN</span> 或 <span style=\"color:red;\">LEFT OUTER JOIN</span> :左向外联接的结果集包括 LEFT OUTER 子句中指定的左表的所有行,而不仅仅是联接列所匹配的行。如果左表的某行在右表中没有匹配行,则在相关联的结果集行中右表的所有选择列表列均为null。</p>\n</li>\n<li><p><span style=\"color:red;\">RIGHT JOIN</span> 或 <span style=\"color:red;\">RIGHT OUTER JOIN</span> :右向外联接是左向外联接的反向联接。将返回右表的所有行。如果右表的某行在左表中没有匹配行,则将为左表返回null。</p>\n</li>\n<li><p><span style=\"color:red;\">FULL JOIN</span> 或 <span style=\"color:red;\">FULL OUTER JOIN</span> :完整外部联接返回左表和右表中的所有行。如果表之间有匹配行,则整个结果集行包含基表的数据值。当某行在另一个表中没有匹配行时,则另一个表的选择列表列包含null。</p>\n</li>\n</ul>\n<h4 id=\"交叉连接(CROSS-JOIN)\"><a href=\"#交叉连接(CROSS-JOIN)\" class=\"headerlink\" title=\"交叉连接(CROSS JOIN)\"></a>交叉连接(CROSS JOIN)</h4><p>交叉联接返回左表中的所有行,左表中的每一行与右表中的所有行组合。交叉联接分显式的和隐式的,均不带ON子句,返回的是两表的乘积,称作笛卡尔积。</p>\n<ul>\n<li><p>隐式的交叉连接,没有CROSS JOIN。</p>\n</li>\n<li><p>显式的交叉连接,没有CROSS JOIN。查询结果同隐式。</p>\n</li>\n</ul>\n<h4 id=\"联合连接(UNION-JOIN)\"><a href=\"#联合连接(UNION-JOIN)\" class=\"headerlink\" title=\"联合连接(UNION JOIN)\"></a>联合连接(UNION JOIN)</h4><p>Oracle、MySQL均不支持,其作用是:找出全外连接和内连接之间差异的所有行。这在数据分析中排错中比较常用。也可以利用数据库的集合操作来实现此功能。这是一种很少见的连接方式。</p>\n<hr>\n<p><span style=\"color:red;\"></span></p>\n<p>###</p>\n"},{"title":"Git和Hexo命令行","date":"2016-08-20T02:58:27.000Z","_content":"\n## Git开始会用\n\n### 基础知识\n\n* 0.配置用户信息\n``` bash\ngit config --global user.name \"userName\"\ngit config --global user.email \"emailAddress\"\n```\n\n* 1.添加文件到stage\n``` bash\n$ git add\n```\n\n* 2.查询stage或版本库里的文件有无改动\n``` bash\n$ git status\n```\n\n* 3.提交文件到git版本库\n``` bash\n$ git commit\n```\n\n* 4.关联一个远程库,先创建当前用户的SSH key(id_rsa私钥,id_rsa.pub公钥),使用公钥绑定远程repository,再remote关联,origin可以为项目名称\n``` bash\n$ cd ~/.ssh\n$ git-keygen -t rsa -C \"emailAddress\"\n$ git remote add origin repositoryAddress\n```\n\n* 5.第一次推送,以后推送,可以没有‘-u’,origin可以为项目名称,master为当前分支名称\n``` bash\n$ git push -u origin master\n```\n\n* 6.从远程pull到本地,origin可以为项目名称,master为当前分支名称\n``` bash\n$ git pull origin master\n```\n\n* 7.查看commit日志,可以得到<commit id>\n``` bash\n$ git log\n$ git reflog\n$ git log --pretty=oneline\n```\n\n* 8.查看文件编辑日志\n``` bash\n$ git diff file.*\n```\n\n## Git深入使用\n\n### 版本控制\n\n* 1.回退版本,当前版本用HEAD表示,上一个版本是HEAD^,再往上HEAD^^,在往上10个可表示为HEAD~10等\n``` bash\n$ git reset --hard HEAD^\n```\n\n* 2.回到指定的版本号\n``` bash\n$ git reset --hard <commit id>\n```\n\n### 撤销修改\n\n* 1.文件修改后没有add或commit操作,即文件还在工作区\n``` bash\n$ git checkout -- file.*\n```\n\n* 2.文件修改后已实现add或commit操作,即文件已添加到了暂存区或者版本区\n``` bash\n$ git reset --hard <commit id>\n```\n\n### 删除文件\n\n* 1.先在工作区删除\n``` bash\n$ rm file.*\n```\n备注:这里可以使用`git checkout -- file.*` 撤销工作区的文件删除\n\n* 2.把删除提交到暂存区\n``` bash\n$ git rm file.*\n```\n\n* 3.在版本库中删除\n``` bash\n$ git commit -m \"delete file.*\"\n```\n\n### 创建分支和合并分支\n\n* 1.查看分支\n``` bash\n$ git branch\n```\n\n* 2.创建分支dev\n``` bash\n$ git branch dev\n```\n\n* 3.切换分支dev\n``` bash\n$ git checkout dev\n```\n\n* 4.切回主分支,合并dev分支\n``` bash\n$ git checkout master\n$ git merge dev\n```\n\n* 5.删除分支\n``` bash\n$ git branch -d dev\n```\n\n* 6.禁用Fast forward模式合并,可以生成commit的日志信息\n``` bash\n$ git merge --no-ff -m\"禁用Fast forward模式合并\" dev\n```\n\n### 添加标签*\n\n* 1.添加标签,相当于commit的提交日志(-m \" info \")\n``` bash\n$ git tag v1.0\n```\n\n* 2.给以前的提交打标签,先查询出所有的提交,再给<commit id>打标签\n``` bash\n$ git log --pretty=oneline --abbrev-commit\n$ git tag v1.0 <commit id>\n```\n\n* 3.带说明的标签,用`-a`指定标签名,用`-m`指定标签说明\n``` bash\n$ git tag -a v1.0 -m\"1.0版本\" <commit id>\n```\n\n* 4.查看标签\n``` bash\n$ git tag\n```\n\n* 5.查看指定标签的说明\n``` bash\n$ git show v1.0\n```\n\n### 操作标签*\n\n* 1.删除标签\n``` bash\n$ git tag -d v1.0\n```\n\n* 2.推送标签\n``` bash\n$ git push origin v1.0\n```\n\n* 3.推送所有标签\n``` bash\n$ git push origin --tags\n```\n\n* 4.本地删除远程标签,先删除本地\n``` bash\n$ git tag -d v1.0\n$ git push origin :refs/tags/v1.0\n```\n\n### 忽略文件*\n\n* 1.在工作区的根目录下创建一个特殊(类似`.git`)的`.gitignore`文件,然后把啊啊要忽略的文件填好\n查看官方解决方案:https://github.com/github/gitignore,例如\n``` bash\n# 忽略掉下面的文件:\nfileName.class\nfileName.temp\n\n```\n\n* 2.提交`.gitignore`文件\n\n\n* 3.忽略`.gitignore`规则,强制提交其中属于忽略的文件\n``` bash\n$ git add -f fileName.class\n```\n\n* 4.检查`.gitignore`中定义的fileName.class文件\n\n``` bash\n$ git check-ignore -v fileName.class\n```\n","source":"_posts/hello-world.md","raw":"---\ntitle: Git和Hexo命令行\ndate: 2016-08-20 10:58:27\ncategories: hexo\ntags: [HEXO]\n---\n\n## Git开始会用\n\n### 基础知识\n\n* 0.配置用户信息\n``` bash\ngit config --global user.name \"userName\"\ngit config --global user.email \"emailAddress\"\n```\n\n* 1.添加文件到stage\n``` bash\n$ git add\n```\n\n* 2.查询stage或版本库里的文件有无改动\n``` bash\n$ git status\n```\n\n* 3.提交文件到git版本库\n``` bash\n$ git commit\n```\n\n* 4.关联一个远程库,先创建当前用户的SSH key(id_rsa私钥,id_rsa.pub公钥),使用公钥绑定远程repository,再remote关联,origin可以为项目名称\n``` bash\n$ cd ~/.ssh\n$ git-keygen -t rsa -C \"emailAddress\"\n$ git remote add origin repositoryAddress\n```\n\n* 5.第一次推送,以后推送,可以没有‘-u’,origin可以为项目名称,master为当前分支名称\n``` bash\n$ git push -u origin master\n```\n\n* 6.从远程pull到本地,origin可以为项目名称,master为当前分支名称\n``` bash\n$ git pull origin master\n```\n\n* 7.查看commit日志,可以得到<commit id>\n``` bash\n$ git log\n$ git reflog\n$ git log --pretty=oneline\n```\n\n* 8.查看文件编辑日志\n``` bash\n$ git diff file.*\n```\n\n## Git深入使用\n\n### 版本控制\n\n* 1.回退版本,当前版本用HEAD表示,上一个版本是HEAD^,再往上HEAD^^,在往上10个可表示为HEAD~10等\n``` bash\n$ git reset --hard HEAD^\n```\n\n* 2.回到指定的版本号\n``` bash\n$ git reset --hard <commit id>\n```\n\n### 撤销修改\n\n* 1.文件修改后没有add或commit操作,即文件还在工作区\n``` bash\n$ git checkout -- file.*\n```\n\n* 2.文件修改后已实现add或commit操作,即文件已添加到了暂存区或者版本区\n``` bash\n$ git reset --hard <commit id>\n```\n\n### 删除文件\n\n* 1.先在工作区删除\n``` bash\n$ rm file.*\n```\n备注:这里可以使用`git checkout -- file.*` 撤销工作区的文件删除\n\n* 2.把删除提交到暂存区\n``` bash\n$ git rm file.*\n```\n\n* 3.在版本库中删除\n``` bash\n$ git commit -m \"delete file.*\"\n```\n\n### 创建分支和合并分支\n\n* 1.查看分支\n``` bash\n$ git branch\n```\n\n* 2.创建分支dev\n``` bash\n$ git branch dev\n```\n\n* 3.切换分支dev\n``` bash\n$ git checkout dev\n```\n\n* 4.切回主分支,合并dev分支\n``` bash\n$ git checkout master\n$ git merge dev\n```\n\n* 5.删除分支\n``` bash\n$ git branch -d dev\n```\n\n* 6.禁用Fast forward模式合并,可以生成commit的日志信息\n``` bash\n$ git merge --no-ff -m\"禁用Fast forward模式合并\" dev\n```\n\n### 添加标签*\n\n* 1.添加标签,相当于commit的提交日志(-m \" info \")\n``` bash\n$ git tag v1.0\n```\n\n* 2.给以前的提交打标签,先查询出所有的提交,再给<commit id>打标签\n``` bash\n$ git log --pretty=oneline --abbrev-commit\n$ git tag v1.0 <commit id>\n```\n\n* 3.带说明的标签,用`-a`指定标签名,用`-m`指定标签说明\n``` bash\n$ git tag -a v1.0 -m\"1.0版本\" <commit id>\n```\n\n* 4.查看标签\n``` bash\n$ git tag\n```\n\n* 5.查看指定标签的说明\n``` bash\n$ git show v1.0\n```\n\n### 操作标签*\n\n* 1.删除标签\n``` bash\n$ git tag -d v1.0\n```\n\n* 2.推送标签\n``` bash\n$ git push origin v1.0\n```\n\n* 3.推送所有标签\n``` bash\n$ git push origin --tags\n```\n\n* 4.本地删除远程标签,先删除本地\n``` bash\n$ git tag -d v1.0\n$ git push origin :refs/tags/v1.0\n```\n\n### 忽略文件*\n\n* 1.在工作区的根目录下创建一个特殊(类似`.git`)的`.gitignore`文件,然后把啊啊要忽略的文件填好\n查看官方解决方案:https://github.com/github/gitignore,例如\n``` bash\n# 忽略掉下面的文件:\nfileName.class\nfileName.temp\n\n```\n\n* 2.提交`.gitignore`文件\n\n\n* 3.忽略`.gitignore`规则,强制提交其中属于忽略的文件\n``` bash\n$ git add -f fileName.class\n```\n\n* 4.检查`.gitignore`中定义的fileName.class文件\n\n``` bash\n$ git check-ignore -v fileName.class\n```\n","slug":"hello-world","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaie4000f3sasckzf13fa","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h2 id=\"Git开始会用\"><a href=\"#Git开始会用\" class=\"headerlink\" title=\"Git开始会用\"></a>Git开始会用</h2><h3 id=\"基础知识\"><a href=\"#基础知识\" class=\"headerlink\" title=\"基础知识\"></a>基础知识</h3><ul>\n<li><p>0.配置用户信息</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">git config --global user.name <span class=\"string\">\"userName\"</span></div><div class=\"line\">git config --global user.email <span class=\"string\">\"emailAddress\"</span></div></pre></td></tr></table></figure>\n</li>\n<li><p>1.添加文件到stage</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git add</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.查询stage或版本库里的文件有无改动</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git status</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.提交文件到git版本库</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git commit</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.关联一个远程库,先创建当前用户的SSH key(id_rsa私钥,id_rsa.pub公钥),使用公钥绑定远程repository,再remote关联,origin可以为项目名称</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ <span class=\"built_in\">cd</span> ~/.ssh</div><div class=\"line\">$ git-keygen -t rsa -C <span class=\"string\">\"emailAddress\"</span></div><div class=\"line\">$ git remote add origin repositoryAddress</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.第一次推送,以后推送,可以没有‘-u’,origin可以为项目名称,master为当前分支名称</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push -u origin master</div></pre></td></tr></table></figure>\n</li>\n<li><p>6.从远程pull到本地,origin可以为项目名称,master为当前分支名称</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git pull origin master</div></pre></td></tr></table></figure>\n</li>\n<li><p>7.查看commit日志,可以得到<commit id=\"\"></commit></p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git <span class=\"built_in\">log</span></div><div class=\"line\">$ git reflog</div><div class=\"line\">$ git <span class=\"built_in\">log</span> --pretty=oneline</div></pre></td></tr></table></figure>\n</li>\n<li><p>8.查看文件编辑日志</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git diff file.*</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h2 id=\"Git深入使用\"><a href=\"#Git深入使用\" class=\"headerlink\" title=\"Git深入使用\"></a>Git深入使用</h2><h3 id=\"版本控制\"><a href=\"#版本控制\" class=\"headerlink\" title=\"版本控制\"></a>版本控制</h3><ul>\n<li><p>1.回退版本,当前版本用HEAD表示,上一个版本是HEAD^,再往上HEAD^^,在往上10个可表示为HEAD~10等</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git reset --hard HEAD^</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.回到指定的版本号</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git reset --hard <commit id></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"撤销修改\"><a href=\"#撤销修改\" class=\"headerlink\" title=\"撤销修改\"></a>撤销修改</h3><ul>\n<li><p>1.文件修改后没有add或commit操作,即文件还在工作区</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git checkout -- file.*</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.文件修改后已实现add或commit操作,即文件已添加到了暂存区或者版本区</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git reset --hard <commit id></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"删除文件\"><a href=\"#删除文件\" class=\"headerlink\" title=\"删除文件\"></a>删除文件</h3><ul>\n<li>1.先在工作区删除<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ rm file.*</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>备注:这里可以使用<code>git checkout -- file.*</code> 撤销工作区的文件删除</p>\n<ul>\n<li><p>2.把删除提交到暂存区</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git rm file.*</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.在版本库中删除</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git commit -m <span class=\"string\">\"delete file.*\"</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"创建分支和合并分支\"><a href=\"#创建分支和合并分支\" class=\"headerlink\" title=\"创建分支和合并分支\"></a>创建分支和合并分支</h3><ul>\n<li><p>1.查看分支</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git branch</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.创建分支dev</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git branch dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.切换分支dev</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git checkout dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.切回主分支,合并dev分支</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git checkout master</div><div class=\"line\">$ git merge dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.删除分支</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git branch <span class=\"_\">-d</span> dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>6.禁用Fast forward模式合并,可以生成commit的日志信息</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git merge --no-ff -m<span class=\"string\">\"禁用Fast forward模式合并\"</span> dev</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"添加标签\"><a href=\"#添加标签\" class=\"headerlink\" title=\"添加标签*\"></a>添加标签*</h3><ul>\n<li><p>1.添加标签,相当于commit的提交日志(-m “ info “)</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag v1.0</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.给以前的提交打标签,先查询出所有的提交,再给<commit id=\"\">打标签</commit></p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git <span class=\"built_in\">log</span> --pretty=oneline --abbrev-commit</div><div class=\"line\">$ git tag v1.0 <commit id></div></pre></td></tr></table></figure>\n</li>\n<li><p>3.带说明的标签,用<code>-a</code>指定标签名,用<code>-m</code>指定标签说明</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag <span class=\"_\">-a</span> v1.0 -m<span class=\"string\">\"1.0版本\"</span> <commit id></div></pre></td></tr></table></figure>\n</li>\n<li><p>4.查看标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.查看指定标签的说明</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git show v1.0</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"操作标签\"><a href=\"#操作标签\" class=\"headerlink\" title=\"操作标签*\"></a>操作标签*</h3><ul>\n<li><p>1.删除标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag <span class=\"_\">-d</span> v1.0</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.推送标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push origin v1.0</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.推送所有标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push origin --tags</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.本地删除远程标签,先删除本地</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag <span class=\"_\">-d</span> v1.0</div><div class=\"line\">$ git push origin :refs/tags/v1.0</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"忽略文件\"><a href=\"#忽略文件\" class=\"headerlink\" title=\"忽略文件*\"></a>忽略文件*</h3><ul>\n<li><p>1.在工作区的根目录下创建一个特殊(类似<code>.git</code>)的<code>.gitignore</code>文件,然后把啊啊要忽略的文件填好<br>查看官方解决方案:<a href=\"https://github.com/github/gitignore,例如\" target=\"_blank\" rel=\"external\">https://github.com/github/gitignore,例如</a></p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\"># 忽略掉下面的文件:</span></div><div class=\"line\">fileName.class</div><div class=\"line\">fileName.temp</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.提交<code>.gitignore</code>文件</p>\n</li>\n</ul>\n<ul>\n<li><p>3.忽略<code>.gitignore</code>规则,强制提交其中属于忽略的文件</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git add <span class=\"_\">-f</span> fileName.class</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.检查<code>.gitignore</code>中定义的fileName.class文件</p>\n</li>\n</ul>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git check-ignore -v fileName.class</div></pre></td></tr></table></figure>\n","excerpt":"","more":"<h2 id=\"Git开始会用\"><a href=\"#Git开始会用\" class=\"headerlink\" title=\"Git开始会用\"></a>Git开始会用</h2><h3 id=\"基础知识\"><a href=\"#基础知识\" class=\"headerlink\" title=\"基础知识\"></a>基础知识</h3><ul>\n<li><p>0.配置用户信息</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">git config --global user.name <span class=\"string\">\"userName\"</span></div><div class=\"line\">git config --global user.email <span class=\"string\">\"emailAddress\"</span></div></pre></td></tr></table></figure>\n</li>\n<li><p>1.添加文件到stage</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git add</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.查询stage或版本库里的文件有无改动</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git status</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.提交文件到git版本库</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git commit</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.关联一个远程库,先创建当前用户的SSH key(id_rsa私钥,id_rsa.pub公钥),使用公钥绑定远程repository,再remote关联,origin可以为项目名称</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ <span class=\"built_in\">cd</span> ~/.ssh</div><div class=\"line\">$ git-keygen -t rsa -C <span class=\"string\">\"emailAddress\"</span></div><div class=\"line\">$ git remote add origin repositoryAddress</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.第一次推送,以后推送,可以没有‘-u’,origin可以为项目名称,master为当前分支名称</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push -u origin master</div></pre></td></tr></table></figure>\n</li>\n<li><p>6.从远程pull到本地,origin可以为项目名称,master为当前分支名称</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git pull origin master</div></pre></td></tr></table></figure>\n</li>\n<li><p>7.查看commit日志,可以得到<commit id></p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git <span class=\"built_in\">log</span></div><div class=\"line\">$ git reflog</div><div class=\"line\">$ git <span class=\"built_in\">log</span> --pretty=oneline</div></pre></td></tr></table></figure>\n</li>\n<li><p>8.查看文件编辑日志</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git diff file.*</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h2 id=\"Git深入使用\"><a href=\"#Git深入使用\" class=\"headerlink\" title=\"Git深入使用\"></a>Git深入使用</h2><h3 id=\"版本控制\"><a href=\"#版本控制\" class=\"headerlink\" title=\"版本控制\"></a>版本控制</h3><ul>\n<li><p>1.回退版本,当前版本用HEAD表示,上一个版本是HEAD^,再往上HEAD^^,在往上10个可表示为HEAD~10等</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git reset --hard HEAD^</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.回到指定的版本号</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git reset --hard <commit id></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"撤销修改\"><a href=\"#撤销修改\" class=\"headerlink\" title=\"撤销修改\"></a>撤销修改</h3><ul>\n<li><p>1.文件修改后没有add或commit操作,即文件还在工作区</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git checkout -- file.*</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.文件修改后已实现add或commit操作,即文件已添加到了暂存区或者版本区</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git reset --hard <commit id></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"删除文件\"><a href=\"#删除文件\" class=\"headerlink\" title=\"删除文件\"></a>删除文件</h3><ul>\n<li>1.先在工作区删除<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ rm file.*</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<p>备注:这里可以使用<code>git checkout -- file.*</code> 撤销工作区的文件删除</p>\n<ul>\n<li><p>2.把删除提交到暂存区</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git rm file.*</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.在版本库中删除</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git commit -m <span class=\"string\">\"delete file.*\"</span></div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"创建分支和合并分支\"><a href=\"#创建分支和合并分支\" class=\"headerlink\" title=\"创建分支和合并分支\"></a>创建分支和合并分支</h3><ul>\n<li><p>1.查看分支</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git branch</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.创建分支dev</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git branch dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.切换分支dev</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git checkout dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.切回主分支,合并dev分支</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git checkout master</div><div class=\"line\">$ git merge dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.删除分支</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git branch <span class=\"_\">-d</span> dev</div></pre></td></tr></table></figure>\n</li>\n<li><p>6.禁用Fast forward模式合并,可以生成commit的日志信息</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git merge --no-ff -m<span class=\"string\">\"禁用Fast forward模式合并\"</span> dev</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"添加标签\"><a href=\"#添加标签\" class=\"headerlink\" title=\"添加标签*\"></a>添加标签*</h3><ul>\n<li><p>1.添加标签,相当于commit的提交日志(-m “ info “)</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag v1.0</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.给以前的提交打标签,先查询出所有的提交,再给<commit id>打标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git <span class=\"built_in\">log</span> --pretty=oneline --abbrev-commit</div><div class=\"line\">$ git tag v1.0 <commit id></div></pre></td></tr></table></figure>\n</li>\n<li><p>3.带说明的标签,用<code>-a</code>指定标签名,用<code>-m</code>指定标签说明</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag <span class=\"_\">-a</span> v1.0 -m<span class=\"string\">\"1.0版本\"</span> <commit id></div></pre></td></tr></table></figure>\n</li>\n<li><p>4.查看标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag</div></pre></td></tr></table></figure>\n</li>\n<li><p>5.查看指定标签的说明</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git show v1.0</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"操作标签\"><a href=\"#操作标签\" class=\"headerlink\" title=\"操作标签*\"></a>操作标签*</h3><ul>\n<li><p>1.删除标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag <span class=\"_\">-d</span> v1.0</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.推送标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push origin v1.0</div></pre></td></tr></table></figure>\n</li>\n<li><p>3.推送所有标签</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git push origin --tags</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.本地删除远程标签,先删除本地</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git tag <span class=\"_\">-d</span> v1.0</div><div class=\"line\">$ git push origin :refs/tags/v1.0</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"忽略文件\"><a href=\"#忽略文件\" class=\"headerlink\" title=\"忽略文件*\"></a>忽略文件*</h3><ul>\n<li><p>1.在工作区的根目录下创建一个特殊(类似<code>.git</code>)的<code>.gitignore</code>文件,然后把啊啊要忽略的文件填好<br>查看官方解决方案:<a href=\"https://github.com/github/gitignore,例如\">https://github.com/github/gitignore,例如</a></p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\"># 忽略掉下面的文件:</span></div><div class=\"line\">fileName.class</div><div class=\"line\">fileName.temp</div></pre></td></tr></table></figure>\n</li>\n<li><p>2.提交<code>.gitignore</code>文件</p>\n</li>\n</ul>\n<ul>\n<li><p>3.忽略<code>.gitignore</code>规则,强制提交其中属于忽略的文件</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git add <span class=\"_\">-f</span> fileName.class</div></pre></td></tr></table></figure>\n</li>\n<li><p>4.检查<code>.gitignore</code>中定义的fileName.class文件</p>\n</li>\n</ul>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">$ git check-ignore -v fileName.class</div></pre></td></tr></table></figure>\n"},{"title":"SSH2三大框架的整合","date":"2016-08-05T15:56:21.000Z","_content":"\n> SSH2框架由Struts2.3.15,Spring3.2.0,Hibernate3.6.10集成。下面记录我在JavaWeb上搭建基于SSH2框架的开发环境。\n\n## jar包\n\n### Struts2用到的jar包\n* asm-3.3.jar\n* asm-commons-3.3.jar\n* asm-tree-3.3.jar\n* commons-fileupload-1.3.jar\n* commons-io-2.0.1.jar\n* commons-lang3-3.1.jar\n* commons-logging-1.1.3.jar\n* freemarker-2.3.19.jar\n* javassist-3.11.0.GA.jar\n* log4j-1.2.17.jar\n* ognl-3.0.6.jar\n* struts2-core-2.3.15.3.jar\n* struts2-json-plugin-2.3.15.3.jar\n* struts2-spring-plugin-2.3.15.3.jar\n* xwork-core-2.3.15.3.jar\n\n### Spring用到的jar包\n* com.springsource.org.aopalliance-1.0.0.jar\n* com.springsource.org.apache.commons.logging-1.1.1.jar\n* com.springsource.org.apache.log4j-1.2.15.jar\n* com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar\n* spring-aop-3.2.0.RELEASE.jar\n* spring-aspects-3.2.0.RELEASE.jar\n* spring-beans-3.2.0.RELEASE.jar\n* spring-context-3.2.0.RELEASE.jar\n* spring-core-3.2.0.RELEASE.jar\n* spring-expression-3.2.0.RELEASE.jar\n* spring-jdbc-3.2.0.RELEASE.jar\n* spring-orm-3.2.0.RELEASE.jar\n* spring-test-3.2.0.RELEASE.jar\n* spring-tx-3.2.0.RELEASE.jar\n* spring-web-3.2.0.RELEASE.jar\n\n### Hibernate用到的jar包\n* antlr-2.7.6.jar\n* commons-collections-3.1.jar\n* dom4j-1.6.1.jar\n* hibernate3.jar\n* hibernate-jpa-2.0-api-1.0.1.Final.jar\n* javassist-3.12.0.GA.jar\n* jta-1.1.jar\n* slf4j-api-1.6.1.jar\n* slf4j-log4j12-1.7.2.jar\n\n### MySQL连接用到的jar包\n* c3p0-0.9.1.jar\n* mysql-connector-java-5.0.4-bin.jar\n\n## web.xml配置\n#### 配置Spring的核心监听器\n <listener>\n <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n </listener>\n#### 配置全局初始化参数\n <context-param>\n \t\t<param-name>contextConfigLocation</param-name>\n \t\t<param-value>classpath:applicationContext.xml</param-value>\n </context-param>\n#### 配置Struts2的核心过滤器\n <filter>\n \t\t<filter-name>struts2</filter-name>\n \t\t<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>\n \t</filter>\n \t<filter-mapping>\n \t\t<filter-name>struts2</filter-name>\n \t\t<url-pattern>/* </url-pattern>\n \t\t<dispatcher>REQUEST</dispatcher>\n \t\t<dispatcher>FORWARD</dispatcher>\n </filter-mapping>\n\n## applicationContext.xml配置\n#### 配置连接池,通过引入外部属性文件配置\n <context:property-placeholder location=\"classpath:jdbc.properties\"/>\n \t<bean id=\"dataSource\" class=\"com.mchange.v2.c3p0.ComboPooledDataSource\">\n \t\t<property name=\"driverClass\" value=\"${jdbc.driver}\"/>\n \t\t<property name=\"jdbcUrl\" value=\"${jdbc.url}\"/>\n \t\t<property name=\"user\" value=\"${jdbc.user}\"/>\n \t\t<property name=\"password\" value=\"${jdbc.password}\"/>\n </bean>\n#### 配置Hibernate的相关属性信息\n <bean id=\"sessionFactory\" class=\"org.springframework.orm.hibernate3.LocalSessionFactoryBean\">\n \t\t<!-- 注入连接池 -->\n \t\t<property name=\"dataSource\" ref=\"dataSource\"/>\n \t\t<!-- 配置Hibernate的其他属性 -->\n \t\t<property name=\"hibernateProperties\">\n \t\t\t<props>\n \t\t\t\t<prop key=\"hibernate.dialect\">org.hibernate.dialect.MySQLDialect</prop>\n \t\t\t\t<prop key=\"hibernate.show_sql\">true</prop>\n \t\t\t\t<prop key=\"hibernate.format_sql\">true</prop>\n \t\t\t\t<prop key=\"hibernate.connection.autocommit\">false</prop>\n \t\t\t\t<prop key=\"hibernate.hbm2ddl.auto\">update</prop>\n \t\t</props>\n </property>\n <!-- 配置Hibernate的映射文件 -->\n <property name=\"mappingResources\">\n \t\t\t<list>\n \t\t\t\t<value>com/yanlin/shop/user/vo/User.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/category/vo/Category.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/product/vo/Product.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/categorysecond/vo/CategorySecond.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/order/vo/Order.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/order/vo/OrderItem.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/adminuser/vo/AdminUser.hbm.xml</value>\n \t\t\t</list>\n \t</property>\n </bean>\n#### 事务管理器的配置\n <bean id=\"transactionManager\" class=\"org.springframework.orm.hibernate3.HibernateTransactionManager\">\n \t\t<property name=\"sessionFactory\" ref=\"sessionFactory\"/>\n </bean>\n#### 开启注解事务\n <tx:annotation-driven transaction-manager=\"transactionManager\"/>\n#### Action的配置\n <bean id=\"xxxAction\" class=\"xxx.action.XxxAction\" scope=\"prototype\">\n <property name=\"xxxService\" ref=\"xxxService\"/>\n </bean>\n#### Service的配置\n <bean id=\"xxxService\" class=\"xxx.service.XxxService\">\n \t\t<property name=\"xxxDao\" ref=\"xxxDao\"/>\n </bean>\n#### Dao的配置\n <bean id=\"xxxDao\" class=\"xxx.dao.XxxDao\">\n \t\t<property name=\"sessionFactory\" ref=\"sessionFactory\"/>\n </bean>\n\n## 外部属性文件配置:jdbc.properties\n jdbc.driver=com.mysql.jdbc.Driver\n jdbc.url=jdbc:mysql:///shop\n jdbc.user=root\n jdbc.password=admin\n\n## Struts.xml的配置\n <struts>\n <constant name=\"struts.devMode\" value=\"false\" />\n\n \t<package name=\"shop\" namespace=\"/\" extends=\"struts-default\">\n <action name=\"xx_*\" class=\"\" method=\"{1}\">\n <result name=\"success\">/xxx.jsp</result>\n </action>\n </package>\n </struts>\n\n## 配置log4j.properties\n ### direct log messages to stdout ###\n log4j.appender.stdout=org.apache.log4j.ConsoleAppender\n log4j.appender.stdout.Target=System.out\n log4j.appender.stdout.layout=org.apache.log4j.PatternLayout\n log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n ### direct messages to file mylog.log ###\n log4j.appender.file=org.apache.log4j.FileAppender\n log4j.appender.file.File=c:/mylog.log\n log4j.appender.file.layout=org.apache.log4j.PatternLayout\n log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n ### set log levels - for more verbose logging change 'info' to 'debug' ###\n\n log4j.rootLogger=info, stdout\n","source":"_posts/SSH2三大框架的整合.md","raw":"---\ntitle: SSH2三大框架的整合\ndate: 2016-08-05 23:56:21\ncategories: 编程\ntags: [Java]\n---\n\n> SSH2框架由Struts2.3.15,Spring3.2.0,Hibernate3.6.10集成。下面记录我在JavaWeb上搭建基于SSH2框架的开发环境。\n\n## jar包\n\n### Struts2用到的jar包\n* asm-3.3.jar\n* asm-commons-3.3.jar\n* asm-tree-3.3.jar\n* commons-fileupload-1.3.jar\n* commons-io-2.0.1.jar\n* commons-lang3-3.1.jar\n* commons-logging-1.1.3.jar\n* freemarker-2.3.19.jar\n* javassist-3.11.0.GA.jar\n* log4j-1.2.17.jar\n* ognl-3.0.6.jar\n* struts2-core-2.3.15.3.jar\n* struts2-json-plugin-2.3.15.3.jar\n* struts2-spring-plugin-2.3.15.3.jar\n* xwork-core-2.3.15.3.jar\n\n### Spring用到的jar包\n* com.springsource.org.aopalliance-1.0.0.jar\n* com.springsource.org.apache.commons.logging-1.1.1.jar\n* com.springsource.org.apache.log4j-1.2.15.jar\n* com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar\n* spring-aop-3.2.0.RELEASE.jar\n* spring-aspects-3.2.0.RELEASE.jar\n* spring-beans-3.2.0.RELEASE.jar\n* spring-context-3.2.0.RELEASE.jar\n* spring-core-3.2.0.RELEASE.jar\n* spring-expression-3.2.0.RELEASE.jar\n* spring-jdbc-3.2.0.RELEASE.jar\n* spring-orm-3.2.0.RELEASE.jar\n* spring-test-3.2.0.RELEASE.jar\n* spring-tx-3.2.0.RELEASE.jar\n* spring-web-3.2.0.RELEASE.jar\n\n### Hibernate用到的jar包\n* antlr-2.7.6.jar\n* commons-collections-3.1.jar\n* dom4j-1.6.1.jar\n* hibernate3.jar\n* hibernate-jpa-2.0-api-1.0.1.Final.jar\n* javassist-3.12.0.GA.jar\n* jta-1.1.jar\n* slf4j-api-1.6.1.jar\n* slf4j-log4j12-1.7.2.jar\n\n### MySQL连接用到的jar包\n* c3p0-0.9.1.jar\n* mysql-connector-java-5.0.4-bin.jar\n\n## web.xml配置\n#### 配置Spring的核心监听器\n <listener>\n <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n </listener>\n#### 配置全局初始化参数\n <context-param>\n \t\t<param-name>contextConfigLocation</param-name>\n \t\t<param-value>classpath:applicationContext.xml</param-value>\n </context-param>\n#### 配置Struts2的核心过滤器\n <filter>\n \t\t<filter-name>struts2</filter-name>\n \t\t<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>\n \t</filter>\n \t<filter-mapping>\n \t\t<filter-name>struts2</filter-name>\n \t\t<url-pattern>/* </url-pattern>\n \t\t<dispatcher>REQUEST</dispatcher>\n \t\t<dispatcher>FORWARD</dispatcher>\n </filter-mapping>\n\n## applicationContext.xml配置\n#### 配置连接池,通过引入外部属性文件配置\n <context:property-placeholder location=\"classpath:jdbc.properties\"/>\n \t<bean id=\"dataSource\" class=\"com.mchange.v2.c3p0.ComboPooledDataSource\">\n \t\t<property name=\"driverClass\" value=\"${jdbc.driver}\"/>\n \t\t<property name=\"jdbcUrl\" value=\"${jdbc.url}\"/>\n \t\t<property name=\"user\" value=\"${jdbc.user}\"/>\n \t\t<property name=\"password\" value=\"${jdbc.password}\"/>\n </bean>\n#### 配置Hibernate的相关属性信息\n <bean id=\"sessionFactory\" class=\"org.springframework.orm.hibernate3.LocalSessionFactoryBean\">\n \t\t<!-- 注入连接池 -->\n \t\t<property name=\"dataSource\" ref=\"dataSource\"/>\n \t\t<!-- 配置Hibernate的其他属性 -->\n \t\t<property name=\"hibernateProperties\">\n \t\t\t<props>\n \t\t\t\t<prop key=\"hibernate.dialect\">org.hibernate.dialect.MySQLDialect</prop>\n \t\t\t\t<prop key=\"hibernate.show_sql\">true</prop>\n \t\t\t\t<prop key=\"hibernate.format_sql\">true</prop>\n \t\t\t\t<prop key=\"hibernate.connection.autocommit\">false</prop>\n \t\t\t\t<prop key=\"hibernate.hbm2ddl.auto\">update</prop>\n \t\t</props>\n </property>\n <!-- 配置Hibernate的映射文件 -->\n <property name=\"mappingResources\">\n \t\t\t<list>\n \t\t\t\t<value>com/yanlin/shop/user/vo/User.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/category/vo/Category.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/product/vo/Product.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/categorysecond/vo/CategorySecond.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/order/vo/Order.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/order/vo/OrderItem.hbm.xml</value>\n \t\t\t\t<value>com/yanlin/shop/adminuser/vo/AdminUser.hbm.xml</value>\n \t\t\t</list>\n \t</property>\n </bean>\n#### 事务管理器的配置\n <bean id=\"transactionManager\" class=\"org.springframework.orm.hibernate3.HibernateTransactionManager\">\n \t\t<property name=\"sessionFactory\" ref=\"sessionFactory\"/>\n </bean>\n#### 开启注解事务\n <tx:annotation-driven transaction-manager=\"transactionManager\"/>\n#### Action的配置\n <bean id=\"xxxAction\" class=\"xxx.action.XxxAction\" scope=\"prototype\">\n <property name=\"xxxService\" ref=\"xxxService\"/>\n </bean>\n#### Service的配置\n <bean id=\"xxxService\" class=\"xxx.service.XxxService\">\n \t\t<property name=\"xxxDao\" ref=\"xxxDao\"/>\n </bean>\n#### Dao的配置\n <bean id=\"xxxDao\" class=\"xxx.dao.XxxDao\">\n \t\t<property name=\"sessionFactory\" ref=\"sessionFactory\"/>\n </bean>\n\n## 外部属性文件配置:jdbc.properties\n jdbc.driver=com.mysql.jdbc.Driver\n jdbc.url=jdbc:mysql:///shop\n jdbc.user=root\n jdbc.password=admin\n\n## Struts.xml的配置\n <struts>\n <constant name=\"struts.devMode\" value=\"false\" />\n\n \t<package name=\"shop\" namespace=\"/\" extends=\"struts-default\">\n <action name=\"xx_*\" class=\"\" method=\"{1}\">\n <result name=\"success\">/xxx.jsp</result>\n </action>\n </package>\n </struts>\n\n## 配置log4j.properties\n ### direct log messages to stdout ###\n log4j.appender.stdout=org.apache.log4j.ConsoleAppender\n log4j.appender.stdout.Target=System.out\n log4j.appender.stdout.layout=org.apache.log4j.PatternLayout\n log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n ### direct messages to file mylog.log ###\n log4j.appender.file=org.apache.log4j.FileAppender\n log4j.appender.file.File=c:/mylog.log\n log4j.appender.file.layout=org.apache.log4j.PatternLayout\n log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n ### set log levels - for more verbose logging change 'info' to 'debug' ###\n\n log4j.rootLogger=info, stdout\n","slug":"SSH2三大框架的整合","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaie7000i3sasemads3e2","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><blockquote>\n<p>SSH2框架由Struts2.3.15,Spring3.2.0,Hibernate3.6.10集成。下面记录我在JavaWeb上搭建基于SSH2框架的开发环境。</p>\n</blockquote>\n<h2 id=\"jar包\"><a href=\"#jar包\" class=\"headerlink\" title=\"jar包\"></a>jar包</h2><h3 id=\"Struts2用到的jar包\"><a href=\"#Struts2用到的jar包\" class=\"headerlink\" title=\"Struts2用到的jar包\"></a>Struts2用到的jar包</h3><ul>\n<li>asm-3.3.jar</li>\n<li>asm-commons-3.3.jar</li>\n<li>asm-tree-3.3.jar</li>\n<li>commons-fileupload-1.3.jar</li>\n<li>commons-io-2.0.1.jar</li>\n<li>commons-lang3-3.1.jar</li>\n<li>commons-logging-1.1.3.jar</li>\n<li>freemarker-2.3.19.jar</li>\n<li>javassist-3.11.0.GA.jar</li>\n<li>log4j-1.2.17.jar</li>\n<li>ognl-3.0.6.jar</li>\n<li>struts2-core-2.3.15.3.jar</li>\n<li>struts2-json-plugin-2.3.15.3.jar</li>\n<li>struts2-spring-plugin-2.3.15.3.jar</li>\n<li>xwork-core-2.3.15.3.jar</li>\n</ul>\n<h3 id=\"Spring用到的jar包\"><a href=\"#Spring用到的jar包\" class=\"headerlink\" title=\"Spring用到的jar包\"></a>Spring用到的jar包</h3><ul>\n<li>com.springsource.org.aopalliance-1.0.0.jar</li>\n<li>com.springsource.org.apache.commons.logging-1.1.1.jar</li>\n<li>com.springsource.org.apache.log4j-1.2.15.jar</li>\n<li>com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar</li>\n<li>spring-aop-3.2.0.RELEASE.jar</li>\n<li>spring-aspects-3.2.0.RELEASE.jar</li>\n<li>spring-beans-3.2.0.RELEASE.jar</li>\n<li>spring-context-3.2.0.RELEASE.jar</li>\n<li>spring-core-3.2.0.RELEASE.jar</li>\n<li>spring-expression-3.2.0.RELEASE.jar</li>\n<li>spring-jdbc-3.2.0.RELEASE.jar</li>\n<li>spring-orm-3.2.0.RELEASE.jar</li>\n<li>spring-test-3.2.0.RELEASE.jar</li>\n<li>spring-tx-3.2.0.RELEASE.jar</li>\n<li>spring-web-3.2.0.RELEASE.jar</li>\n</ul>\n<h3 id=\"Hibernate用到的jar包\"><a href=\"#Hibernate用到的jar包\" class=\"headerlink\" title=\"Hibernate用到的jar包\"></a>Hibernate用到的jar包</h3><ul>\n<li>antlr-2.7.6.jar</li>\n<li>commons-collections-3.1.jar</li>\n<li>dom4j-1.6.1.jar</li>\n<li>hibernate3.jar</li>\n<li>hibernate-jpa-2.0-api-1.0.1.Final.jar</li>\n<li>javassist-3.12.0.GA.jar</li>\n<li>jta-1.1.jar</li>\n<li>slf4j-api-1.6.1.jar</li>\n<li>slf4j-log4j12-1.7.2.jar</li>\n</ul>\n<h3 id=\"MySQL连接用到的jar包\"><a href=\"#MySQL连接用到的jar包\" class=\"headerlink\" title=\"MySQL连接用到的jar包\"></a>MySQL连接用到的jar包</h3><ul>\n<li>c3p0-0.9.1.jar</li>\n<li>mysql-connector-java-5.0.4-bin.jar</li>\n</ul>\n<h2 id=\"web-xml配置\"><a href=\"#web-xml配置\" class=\"headerlink\" title=\"web.xml配置\"></a>web.xml配置</h2><h4 id=\"配置Spring的核心监听器\"><a href=\"#配置Spring的核心监听器\" class=\"headerlink\" title=\"配置Spring的核心监听器\"></a>配置Spring的核心监听器</h4><pre><code><listener>\n <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n</listener>\n</code></pre><h4 id=\"配置全局初始化参数\"><a href=\"#配置全局初始化参数\" class=\"headerlink\" title=\"配置全局初始化参数\"></a>配置全局初始化参数</h4><pre><code><context-param>\n <param-name>contextConfigLocation</param-name>\n <param-value>classpath:applicationContext.xml</param-value>\n</context-param>\n</code></pre><h4 id=\"配置Struts2的核心过滤器\"><a href=\"#配置Struts2的核心过滤器\" class=\"headerlink\" title=\"配置Struts2的核心过滤器\"></a>配置Struts2的核心过滤器</h4><pre><code><filter>\n <filter-name>struts2</filter-name>\n <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>\n </filter>\n <filter-mapping>\n <filter-name>struts2</filter-name>\n <url-pattern>/* </url-pattern>\n <dispatcher>REQUEST</dispatcher>\n <dispatcher>FORWARD</dispatcher>\n </filter-mapping>\n</code></pre><h2 id=\"applicationContext-xml配置\"><a href=\"#applicationContext-xml配置\" class=\"headerlink\" title=\"applicationContext.xml配置\"></a>applicationContext.xml配置</h2><h4 id=\"配置连接池,通过引入外部属性文件配置\"><a href=\"#配置连接池,通过引入外部属性文件配置\" class=\"headerlink\" title=\"配置连接池,通过引入外部属性文件配置\"></a>配置连接池,通过引入外部属性文件配置</h4><pre><code><context:property-placeholder location="classpath:jdbc.properties"/>\n <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">\n <property name="driverClass" value="${jdbc.driver}"/>\n <property name="jdbcUrl" value="${jdbc.url}"/>\n <property name="user" value="${jdbc.user}"/>\n <property name="password" value="${jdbc.password}"/>\n</bean>\n</code></pre><h4 id=\"配置Hibernate的相关属性信息\"><a href=\"#配置Hibernate的相关属性信息\" class=\"headerlink\" title=\"配置Hibernate的相关属性信息\"></a>配置Hibernate的相关属性信息</h4><pre><code><bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">\n <!-- 注入连接池 -->\n <property name="dataSource" ref="dataSource"/>\n <!-- 配置Hibernate的其他属性 -->\n <property name="hibernateProperties">\n <props>\n <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>\n <prop key="hibernate.show_sql">true</prop>\n <prop key="hibernate.format_sql">true</prop>\n <prop key="hibernate.connection.autocommit">false</prop>\n <prop key="hibernate.hbm2ddl.auto">update</prop>\n </props>\n</property>\n<!-- 配置Hibernate的映射文件 -->\n<property name="mappingResources">\n <list>\n <value>com/yanlin/shop/user/vo/User.hbm.xml</value>\n <value>com/yanlin/shop/category/vo/Category.hbm.xml</value>\n <value>com/yanlin/shop/product/vo/Product.hbm.xml</value>\n <value>com/yanlin/shop/categorysecond/vo/CategorySecond.hbm.xml</value>\n <value>com/yanlin/shop/order/vo/Order.hbm.xml</value>\n <value>com/yanlin/shop/order/vo/OrderItem.hbm.xml</value>\n <value>com/yanlin/shop/adminuser/vo/AdminUser.hbm.xml</value>\n </list>\n </property>\n</bean>\n</code></pre><h4 id=\"事务管理器的配置\"><a href=\"#事务管理器的配置\" class=\"headerlink\" title=\"事务管理器的配置\"></a>事务管理器的配置</h4><pre><code><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">\n <property name="sessionFactory" ref="sessionFactory"/>\n</bean>\n</code></pre><h4 id=\"开启注解事务\"><a href=\"#开启注解事务\" class=\"headerlink\" title=\"开启注解事务\"></a>开启注解事务</h4><pre><code><tx:annotation-driven transaction-manager="transactionManager"/>\n</code></pre><h4 id=\"Action的配置\"><a href=\"#Action的配置\" class=\"headerlink\" title=\"Action的配置\"></a>Action的配置</h4><pre><code><bean id="xxxAction" class="xxx.action.XxxAction" scope="prototype">\n <property name="xxxService" ref="xxxService"/>\n</bean>\n</code></pre><h4 id=\"Service的配置\"><a href=\"#Service的配置\" class=\"headerlink\" title=\"Service的配置\"></a>Service的配置</h4><pre><code><bean id="xxxService" class="xxx.service.XxxService">\n <property name="xxxDao" ref="xxxDao"/>\n</bean>\n</code></pre><h4 id=\"Dao的配置\"><a href=\"#Dao的配置\" class=\"headerlink\" title=\"Dao的配置\"></a>Dao的配置</h4><pre><code><bean id="xxxDao" class="xxx.dao.XxxDao">\n <property name="sessionFactory" ref="sessionFactory"/>\n</bean>\n</code></pre><h2 id=\"外部属性文件配置-jdbc-properties\"><a href=\"#外部属性文件配置-jdbc-properties\" class=\"headerlink\" title=\"外部属性文件配置:jdbc.properties\"></a>外部属性文件配置:jdbc.properties</h2><pre><code>jdbc.driver=com.mysql.jdbc.Driver\njdbc.url=jdbc:mysql:///shop\njdbc.user=root\njdbc.password=admin\n</code></pre><h2 id=\"Struts-xml的配置\"><a href=\"#Struts-xml的配置\" class=\"headerlink\" title=\"Struts.xml的配置\"></a>Struts.xml的配置</h2><pre><code><struts>\n <constant name="struts.devMode" value="false" />\n\n <package name="shop" namespace="/" extends="struts-default">\n <action name="xx_*" class="" method="{1}">\n <result name="success">/xxx.jsp</result>\n </action>\n </package>\n</struts>\n</code></pre><h2 id=\"配置log4j-properties\"><a href=\"#配置log4j-properties\" class=\"headerlink\" title=\"配置log4j.properties\"></a>配置log4j.properties</h2><pre><code>### direct log messages to stdout ###\nlog4j.appender.stdout=org.apache.log4j.ConsoleAppender\nlog4j.appender.stdout.Target=System.out\nlog4j.appender.stdout.layout=org.apache.log4j.PatternLayout\nlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n### direct messages to file mylog.log ###\nlog4j.appender.file=org.apache.log4j.FileAppender\nlog4j.appender.file.File=c:/mylog.log\nlog4j.appender.file.layout=org.apache.log4j.PatternLayout\nlog4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n### set log levels - for more verbose logging change 'info' to 'debug' ###\n\nlog4j.rootLogger=info, stdout\n</code></pre>","excerpt":"","more":"<blockquote>\n<p>SSH2框架由Struts2.3.15,Spring3.2.0,Hibernate3.6.10集成。下面记录我在JavaWeb上搭建基于SSH2框架的开发环境。</p>\n</blockquote>\n<h2 id=\"jar包\"><a href=\"#jar包\" class=\"headerlink\" title=\"jar包\"></a>jar包</h2><h3 id=\"Struts2用到的jar包\"><a href=\"#Struts2用到的jar包\" class=\"headerlink\" title=\"Struts2用到的jar包\"></a>Struts2用到的jar包</h3><ul>\n<li>asm-3.3.jar</li>\n<li>asm-commons-3.3.jar</li>\n<li>asm-tree-3.3.jar</li>\n<li>commons-fileupload-1.3.jar</li>\n<li>commons-io-2.0.1.jar</li>\n<li>commons-lang3-3.1.jar</li>\n<li>commons-logging-1.1.3.jar</li>\n<li>freemarker-2.3.19.jar</li>\n<li>javassist-3.11.0.GA.jar</li>\n<li>log4j-1.2.17.jar</li>\n<li>ognl-3.0.6.jar</li>\n<li>struts2-core-2.3.15.3.jar</li>\n<li>struts2-json-plugin-2.3.15.3.jar</li>\n<li>struts2-spring-plugin-2.3.15.3.jar</li>\n<li>xwork-core-2.3.15.3.jar</li>\n</ul>\n<h3 id=\"Spring用到的jar包\"><a href=\"#Spring用到的jar包\" class=\"headerlink\" title=\"Spring用到的jar包\"></a>Spring用到的jar包</h3><ul>\n<li>com.springsource.org.aopalliance-1.0.0.jar</li>\n<li>com.springsource.org.apache.commons.logging-1.1.1.jar</li>\n<li>com.springsource.org.apache.log4j-1.2.15.jar</li>\n<li>com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar</li>\n<li>spring-aop-3.2.0.RELEASE.jar</li>\n<li>spring-aspects-3.2.0.RELEASE.jar</li>\n<li>spring-beans-3.2.0.RELEASE.jar</li>\n<li>spring-context-3.2.0.RELEASE.jar</li>\n<li>spring-core-3.2.0.RELEASE.jar</li>\n<li>spring-expression-3.2.0.RELEASE.jar</li>\n<li>spring-jdbc-3.2.0.RELEASE.jar</li>\n<li>spring-orm-3.2.0.RELEASE.jar</li>\n<li>spring-test-3.2.0.RELEASE.jar</li>\n<li>spring-tx-3.2.0.RELEASE.jar</li>\n<li>spring-web-3.2.0.RELEASE.jar</li>\n</ul>\n<h3 id=\"Hibernate用到的jar包\"><a href=\"#Hibernate用到的jar包\" class=\"headerlink\" title=\"Hibernate用到的jar包\"></a>Hibernate用到的jar包</h3><ul>\n<li>antlr-2.7.6.jar</li>\n<li>commons-collections-3.1.jar</li>\n<li>dom4j-1.6.1.jar</li>\n<li>hibernate3.jar</li>\n<li>hibernate-jpa-2.0-api-1.0.1.Final.jar</li>\n<li>javassist-3.12.0.GA.jar</li>\n<li>jta-1.1.jar</li>\n<li>slf4j-api-1.6.1.jar</li>\n<li>slf4j-log4j12-1.7.2.jar</li>\n</ul>\n<h3 id=\"MySQL连接用到的jar包\"><a href=\"#MySQL连接用到的jar包\" class=\"headerlink\" title=\"MySQL连接用到的jar包\"></a>MySQL连接用到的jar包</h3><ul>\n<li>c3p0-0.9.1.jar</li>\n<li>mysql-connector-java-5.0.4-bin.jar</li>\n</ul>\n<h2 id=\"web-xml配置\"><a href=\"#web-xml配置\" class=\"headerlink\" title=\"web.xml配置\"></a>web.xml配置</h2><h4 id=\"配置Spring的核心监听器\"><a href=\"#配置Spring的核心监听器\" class=\"headerlink\" title=\"配置Spring的核心监听器\"></a>配置Spring的核心监听器</h4><pre><code><listener>\n <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n</listener>\n</code></pre><h4 id=\"配置全局初始化参数\"><a href=\"#配置全局初始化参数\" class=\"headerlink\" title=\"配置全局初始化参数\"></a>配置全局初始化参数</h4><pre><code><context-param>\n <param-name>contextConfigLocation</param-name>\n <param-value>classpath:applicationContext.xml</param-value>\n</context-param>\n</code></pre><h4 id=\"配置Struts2的核心过滤器\"><a href=\"#配置Struts2的核心过滤器\" class=\"headerlink\" title=\"配置Struts2的核心过滤器\"></a>配置Struts2的核心过滤器</h4><pre><code><filter>\n <filter-name>struts2</filter-name>\n <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>\n </filter>\n <filter-mapping>\n <filter-name>struts2</filter-name>\n <url-pattern>/* </url-pattern>\n <dispatcher>REQUEST</dispatcher>\n <dispatcher>FORWARD</dispatcher>\n </filter-mapping>\n</code></pre><h2 id=\"applicationContext-xml配置\"><a href=\"#applicationContext-xml配置\" class=\"headerlink\" title=\"applicationContext.xml配置\"></a>applicationContext.xml配置</h2><h4 id=\"配置连接池,通过引入外部属性文件配置\"><a href=\"#配置连接池,通过引入外部属性文件配置\" class=\"headerlink\" title=\"配置连接池,通过引入外部属性文件配置\"></a>配置连接池,通过引入外部属性文件配置</h4><pre><code><context:property-placeholder location="classpath:jdbc.properties"/>\n <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">\n <property name="driverClass" value="${jdbc.driver}"/>\n <property name="jdbcUrl" value="${jdbc.url}"/>\n <property name="user" value="${jdbc.user}"/>\n <property name="password" value="${jdbc.password}"/>\n</bean>\n</code></pre><h4 id=\"配置Hibernate的相关属性信息\"><a href=\"#配置Hibernate的相关属性信息\" class=\"headerlink\" title=\"配置Hibernate的相关属性信息\"></a>配置Hibernate的相关属性信息</h4><pre><code><bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">\n <!-- 注入连接池 -->\n <property name="dataSource" ref="dataSource"/>\n <!-- 配置Hibernate的其他属性 -->\n <property name="hibernateProperties">\n <props>\n <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>\n <prop key="hibernate.show_sql">true</prop>\n <prop key="hibernate.format_sql">true</prop>\n <prop key="hibernate.connection.autocommit">false</prop>\n <prop key="hibernate.hbm2ddl.auto">update</prop>\n </props>\n</property>\n<!-- 配置Hibernate的映射文件 -->\n<property name="mappingResources">\n <list>\n <value>com/yanlin/shop/user/vo/User.hbm.xml</value>\n <value>com/yanlin/shop/category/vo/Category.hbm.xml</value>\n <value>com/yanlin/shop/product/vo/Product.hbm.xml</value>\n <value>com/yanlin/shop/categorysecond/vo/CategorySecond.hbm.xml</value>\n <value>com/yanlin/shop/order/vo/Order.hbm.xml</value>\n <value>com/yanlin/shop/order/vo/OrderItem.hbm.xml</value>\n <value>com/yanlin/shop/adminuser/vo/AdminUser.hbm.xml</value>\n </list>\n </property>\n</bean>\n</code></pre><h4 id=\"事务管理器的配置\"><a href=\"#事务管理器的配置\" class=\"headerlink\" title=\"事务管理器的配置\"></a>事务管理器的配置</h4><pre><code><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">\n <property name="sessionFactory" ref="sessionFactory"/>\n</bean>\n</code></pre><h4 id=\"开启注解事务\"><a href=\"#开启注解事务\" class=\"headerlink\" title=\"开启注解事务\"></a>开启注解事务</h4><pre><code><tx:annotation-driven transaction-manager="transactionManager"/>\n</code></pre><h4 id=\"Action的配置\"><a href=\"#Action的配置\" class=\"headerlink\" title=\"Action的配置\"></a>Action的配置</h4><pre><code><bean id="xxxAction" class="xxx.action.XxxAction" scope="prototype">\n <property name="xxxService" ref="xxxService"/>\n</bean>\n</code></pre><h4 id=\"Service的配置\"><a href=\"#Service的配置\" class=\"headerlink\" title=\"Service的配置\"></a>Service的配置</h4><pre><code><bean id="xxxService" class="xxx.service.XxxService">\n <property name="xxxDao" ref="xxxDao"/>\n</bean>\n</code></pre><h4 id=\"Dao的配置\"><a href=\"#Dao的配置\" class=\"headerlink\" title=\"Dao的配置\"></a>Dao的配置</h4><pre><code><bean id="xxxDao" class="xxx.dao.XxxDao">\n <property name="sessionFactory" ref="sessionFactory"/>\n</bean>\n</code></pre><h2 id=\"外部属性文件配置-jdbc-properties\"><a href=\"#外部属性文件配置-jdbc-properties\" class=\"headerlink\" title=\"外部属性文件配置:jdbc.properties\"></a>外部属性文件配置:jdbc.properties</h2><pre><code>jdbc.driver=com.mysql.jdbc.Driver\njdbc.url=jdbc:mysql:///shop\njdbc.user=root\njdbc.password=admin\n</code></pre><h2 id=\"Struts-xml的配置\"><a href=\"#Struts-xml的配置\" class=\"headerlink\" title=\"Struts.xml的配置\"></a>Struts.xml的配置</h2><pre><code><struts>\n <constant name="struts.devMode" value="false" />\n\n <package name="shop" namespace="/" extends="struts-default">\n <action name="xx_*" class="" method="{1}">\n <result name="success">/xxx.jsp</result>\n </action>\n </package>\n</struts>\n</code></pre><h2 id=\"配置log4j-properties\"><a href=\"#配置log4j-properties\" class=\"headerlink\" title=\"配置log4j.properties\"></a>配置log4j.properties</h2><pre><code>### direct log messages to stdout ###\nlog4j.appender.stdout=org.apache.log4j.ConsoleAppender\nlog4j.appender.stdout.Target=System.out\nlog4j.appender.stdout.layout=org.apache.log4j.PatternLayout\nlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n### direct messages to file mylog.log ###\nlog4j.appender.file=org.apache.log4j.FileAppender\nlog4j.appender.file.File=c:/mylog.log\nlog4j.appender.file.layout=org.apache.log4j.PatternLayout\nlog4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n\n\n### set log levels - for more verbose logging change 'info' to 'debug' ###\n\nlog4j.rootLogger=info, stdout\n</code></pre>"},{"title":"java经典程序设计","date":"2016-07-27T16:19:52.000Z","_content":"\n### 程序一\n>题目:(古典问题)有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一 对兔子,假如兔子都不死,问每个月的兔子总数为多少?\n\n程序分析:兔子的规律为数列1,1,2,3,5,8,13,21....\n\n### 程序二\n>题目:判断101-200之间有多少个素数,并输出所有素数。\n\n程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,\n则表明此数不是素数,反之是素数。\n\n### 程序三\n>打印出所有的\"水仙花数\",所谓\"水仙花数\"是指一个三位数,其各位数字立方和等于该数本身。例如: 153是一个\"水仙花数\",因为153=1的三次方+5的三次方+3的三次方。\n\n程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。\n\n### 程序四\n>将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。\n\n程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成:\n(1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。\n(2)如果n<>k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,重复执行第一步。\n(3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。\n\n### 程序五\n>利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下 的用C表示。\n\n程序分析:(a>b)?a:b 这是条件运算符的基本例子。\n\n### 程序六\n>输入两个正整数m和n,求其最大公约数和最小公倍数。\n\n程序分析:利用辗除法。\n\n### 程序七\n>输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。\n\n程序分析:利用Map集合,key为字符,value为字符个数\n\n### 程序八\n>求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加), 几个数相加有键盘控制。\n\n程序分析:关键是计算出每一项的值。\n\n### 程序九\n>一个数如果恰好等于它的因子之和,这个数就称为\"完数\"。例如6=1+2+3.编程 找出1000以内的所有完 数。\n\n程序分析:\n\n### 程序十\n>一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高?\n\n程序分析:\n\n### 程序十一\n>有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?\n\n程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。\n\n### 程序十二\n>企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万 元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部 分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可 提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?\n\n程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。\n\n### 程序十三\n>一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?\n\n程序设计:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足 如下条件,即是结果。请看具体分析:\n\n### 程序十四\n>输入某年某月某日,判断这一天是这一年的第几天?\n\n程序设计:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且 输入月份大于3时需考虑多加一天。\n\n### 程序十五\n>输入三个整数x,y,z,请把这三个数由小到大输出。\n\n程序设计:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x 与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。\n\n### 程序十六\n>输出9*9口诀。\n\n程序设计:程序分析:分行与列考虑,共9行9列,i 控制行,j 控制列。\n","source":"_posts/java经典程序设计.md","raw":"---\ntitle: java经典程序设计\ndate: 2016-07-28 00:19:52\ncategories: 编程 \ntags: [Java] \n---\n\n### 程序一\n>题目:(古典问题)有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一 对兔子,假如兔子都不死,问每个月的兔子总数为多少?\n\n程序分析:兔子的规律为数列1,1,2,3,5,8,13,21....\n\n### 程序二\n>题目:判断101-200之间有多少个素数,并输出所有素数。\n\n程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,\n则表明此数不是素数,反之是素数。\n\n### 程序三\n>打印出所有的\"水仙花数\",所谓\"水仙花数\"是指一个三位数,其各位数字立方和等于该数本身。例如: 153是一个\"水仙花数\",因为153=1的三次方+5的三次方+3的三次方。\n\n程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。\n\n### 程序四\n>将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。\n\n程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成:\n(1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。\n(2)如果n<>k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,重复执行第一步。\n(3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。\n\n### 程序五\n>利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下 的用C表示。\n\n程序分析:(a>b)?a:b 这是条件运算符的基本例子。\n\n### 程序六\n>输入两个正整数m和n,求其最大公约数和最小公倍数。\n\n程序分析:利用辗除法。\n\n### 程序七\n>输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。\n\n程序分析:利用Map集合,key为字符,value为字符个数\n\n### 程序八\n>求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加), 几个数相加有键盘控制。\n\n程序分析:关键是计算出每一项的值。\n\n### 程序九\n>一个数如果恰好等于它的因子之和,这个数就称为\"完数\"。例如6=1+2+3.编程 找出1000以内的所有完 数。\n\n程序分析:\n\n### 程序十\n>一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高?\n\n程序分析:\n\n### 程序十一\n>有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?\n\n程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。\n\n### 程序十二\n>企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万 元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部 分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可 提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?\n\n程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。\n\n### 程序十三\n>一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?\n\n程序设计:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足 如下条件,即是结果。请看具体分析:\n\n### 程序十四\n>输入某年某月某日,判断这一天是这一年的第几天?\n\n程序设计:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且 输入月份大于3时需考虑多加一天。\n\n### 程序十五\n>输入三个整数x,y,z,请把这三个数由小到大输出。\n\n程序设计:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x 与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。\n\n### 程序十六\n>输出9*9口诀。\n\n程序设计:程序分析:分行与列考虑,共9行9列,i 控制行,j 控制列。\n","slug":"java经典程序设计","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaie9000j3sasd8fe17d8","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"程序一\"><a href=\"#程序一\" class=\"headerlink\" title=\"程序一\"></a>程序一</h3><blockquote>\n<p>题目:(古典问题)有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一 对兔子,假如兔子都不死,问每个月的兔子总数为多少?</p>\n</blockquote>\n<p>程序分析:兔子的规律为数列1,1,2,3,5,8,13,21….</p>\n<h3 id=\"程序二\"><a href=\"#程序二\" class=\"headerlink\" title=\"程序二\"></a>程序二</h3><blockquote>\n<p>题目:判断101-200之间有多少个素数,并输出所有素数。</p>\n</blockquote>\n<p>程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,<br>则表明此数不是素数,反之是素数。</p>\n<h3 id=\"程序三\"><a href=\"#程序三\" class=\"headerlink\" title=\"程序三\"></a>程序三</h3><blockquote>\n<p>打印出所有的”水仙花数”,所谓”水仙花数”是指一个三位数,其各位数字立方和等于该数本身。例如: 153是一个”水仙花数”,因为153=1的三次方+5的三次方+3的三次方。</p>\n</blockquote>\n<p>程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。</p>\n<h3 id=\"程序四\"><a href=\"#程序四\" class=\"headerlink\" title=\"程序四\"></a>程序四</h3><blockquote>\n<p>将一个正整数分解质因数。例如:输入90,打印出90=2<em>3</em>3*5。</p>\n</blockquote>\n<p>程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成:<br>(1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。<br>(2)如果n<>k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,重复执行第一步。<br>(3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。</p>\n<h3 id=\"程序五\"><a href=\"#程序五\" class=\"headerlink\" title=\"程序五\"></a>程序五</h3><blockquote>\n<p>利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下 的用C表示。</p>\n</blockquote>\n<p>程序分析:(a>b)?a:b 这是条件运算符的基本例子。</p>\n<h3 id=\"程序六\"><a href=\"#程序六\" class=\"headerlink\" title=\"程序六\"></a>程序六</h3><blockquote>\n<p>输入两个正整数m和n,求其最大公约数和最小公倍数。</p>\n</blockquote>\n<p>程序分析:利用辗除法。</p>\n<h3 id=\"程序七\"><a href=\"#程序七\" class=\"headerlink\" title=\"程序七\"></a>程序七</h3><blockquote>\n<p>输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。</p>\n</blockquote>\n<p>程序分析:利用Map集合,key为字符,value为字符个数</p>\n<h3 id=\"程序八\"><a href=\"#程序八\" class=\"headerlink\" title=\"程序八\"></a>程序八</h3><blockquote>\n<p>求s=a+aa+aaa+aaaa+aa…a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加), 几个数相加有键盘控制。</p>\n</blockquote>\n<p>程序分析:关键是计算出每一项的值。</p>\n<h3 id=\"程序九\"><a href=\"#程序九\" class=\"headerlink\" title=\"程序九\"></a>程序九</h3><blockquote>\n<p>一个数如果恰好等于它的因子之和,这个数就称为”完数”。例如6=1+2+3.编程 找出1000以内的所有完 数。</p>\n</blockquote>\n<p>程序分析:</p>\n<h3 id=\"程序十\"><a href=\"#程序十\" class=\"headerlink\" title=\"程序十\"></a>程序十</h3><blockquote>\n<p>一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高?</p>\n</blockquote>\n<p>程序分析:</p>\n<h3 id=\"程序十一\"><a href=\"#程序十一\" class=\"headerlink\" title=\"程序十一\"></a>程序十一</h3><blockquote>\n<p>有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?</p>\n</blockquote>\n<p>程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。</p>\n<h3 id=\"程序十二\"><a href=\"#程序十二\" class=\"headerlink\" title=\"程序十二\"></a>程序十二</h3><blockquote>\n<p>企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万 元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部 分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可 提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?</p>\n</blockquote>\n<p>程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。</p>\n<h3 id=\"程序十三\"><a href=\"#程序十三\" class=\"headerlink\" title=\"程序十三\"></a>程序十三</h3><blockquote>\n<p>一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?</p>\n</blockquote>\n<p>程序设计:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足 如下条件,即是结果。请看具体分析:</p>\n<h3 id=\"程序十四\"><a href=\"#程序十四\" class=\"headerlink\" title=\"程序十四\"></a>程序十四</h3><blockquote>\n<p>输入某年某月某日,判断这一天是这一年的第几天?</p>\n</blockquote>\n<p>程序设计:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且 输入月份大于3时需考虑多加一天。</p>\n<h3 id=\"程序十五\"><a href=\"#程序十五\" class=\"headerlink\" title=\"程序十五\"></a>程序十五</h3><blockquote>\n<p>输入三个整数x,y,z,请把这三个数由小到大输出。</p>\n</blockquote>\n<p>程序设计:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x 与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。</p>\n<h3 id=\"程序十六\"><a href=\"#程序十六\" class=\"headerlink\" title=\"程序十六\"></a>程序十六</h3><blockquote>\n<p>输出9*9口诀。</p>\n</blockquote>\n<p>程序设计:程序分析:分行与列考虑,共9行9列,i 控制行,j 控制列。</p>\n","excerpt":"","more":"<h3 id=\"程序一\"><a href=\"#程序一\" class=\"headerlink\" title=\"程序一\"></a>程序一</h3><blockquote>\n<p>题目:(古典问题)有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一 对兔子,假如兔子都不死,问每个月的兔子总数为多少?</p>\n</blockquote>\n<p>程序分析:兔子的规律为数列1,1,2,3,5,8,13,21….</p>\n<h3 id=\"程序二\"><a href=\"#程序二\" class=\"headerlink\" title=\"程序二\"></a>程序二</h3><blockquote>\n<p>题目:判断101-200之间有多少个素数,并输出所有素数。</p>\n</blockquote>\n<p>程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,<br>则表明此数不是素数,反之是素数。</p>\n<h3 id=\"程序三\"><a href=\"#程序三\" class=\"headerlink\" title=\"程序三\"></a>程序三</h3><blockquote>\n<p>打印出所有的”水仙花数”,所谓”水仙花数”是指一个三位数,其各位数字立方和等于该数本身。例如: 153是一个”水仙花数”,因为153=1的三次方+5的三次方+3的三次方。</p>\n</blockquote>\n<p>程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。</p>\n<h3 id=\"程序四\"><a href=\"#程序四\" class=\"headerlink\" title=\"程序四\"></a>程序四</h3><blockquote>\n<p>将一个正整数分解质因数。例如:输入90,打印出90=2<em>3</em>3*5。</p>\n</blockquote>\n<p>程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成:<br>(1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。<br>(2)如果n<>k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,重复执行第一步。<br>(3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。</p>\n<h3 id=\"程序五\"><a href=\"#程序五\" class=\"headerlink\" title=\"程序五\"></a>程序五</h3><blockquote>\n<p>利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下 的用C表示。</p>\n</blockquote>\n<p>程序分析:(a>b)?a:b 这是条件运算符的基本例子。</p>\n<h3 id=\"程序六\"><a href=\"#程序六\" class=\"headerlink\" title=\"程序六\"></a>程序六</h3><blockquote>\n<p>输入两个正整数m和n,求其最大公约数和最小公倍数。</p>\n</blockquote>\n<p>程序分析:利用辗除法。</p>\n<h3 id=\"程序七\"><a href=\"#程序七\" class=\"headerlink\" title=\"程序七\"></a>程序七</h3><blockquote>\n<p>输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。</p>\n</blockquote>\n<p>程序分析:利用Map集合,key为字符,value为字符个数</p>\n<h3 id=\"程序八\"><a href=\"#程序八\" class=\"headerlink\" title=\"程序八\"></a>程序八</h3><blockquote>\n<p>求s=a+aa+aaa+aaaa+aa…a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加), 几个数相加有键盘控制。</p>\n</blockquote>\n<p>程序分析:关键是计算出每一项的值。</p>\n<h3 id=\"程序九\"><a href=\"#程序九\" class=\"headerlink\" title=\"程序九\"></a>程序九</h3><blockquote>\n<p>一个数如果恰好等于它的因子之和,这个数就称为”完数”。例如6=1+2+3.编程 找出1000以内的所有完 数。</p>\n</blockquote>\n<p>程序分析:</p>\n<h3 id=\"程序十\"><a href=\"#程序十\" class=\"headerlink\" title=\"程序十\"></a>程序十</h3><blockquote>\n<p>一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高?</p>\n</blockquote>\n<p>程序分析:</p>\n<h3 id=\"程序十一\"><a href=\"#程序十一\" class=\"headerlink\" title=\"程序十一\"></a>程序十一</h3><blockquote>\n<p>有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?</p>\n</blockquote>\n<p>程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。</p>\n<h3 id=\"程序十二\"><a href=\"#程序十二\" class=\"headerlink\" title=\"程序十二\"></a>程序十二</h3><blockquote>\n<p>企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万 元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部 分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可 提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?</p>\n</blockquote>\n<p>程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。</p>\n<h3 id=\"程序十三\"><a href=\"#程序十三\" class=\"headerlink\" title=\"程序十三\"></a>程序十三</h3><blockquote>\n<p>一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?</p>\n</blockquote>\n<p>程序设计:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足 如下条件,即是结果。请看具体分析:</p>\n<h3 id=\"程序十四\"><a href=\"#程序十四\" class=\"headerlink\" title=\"程序十四\"></a>程序十四</h3><blockquote>\n<p>输入某年某月某日,判断这一天是这一年的第几天?</p>\n</blockquote>\n<p>程序设计:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且 输入月份大于3时需考虑多加一天。</p>\n<h3 id=\"程序十五\"><a href=\"#程序十五\" class=\"headerlink\" title=\"程序十五\"></a>程序十五</h3><blockquote>\n<p>输入三个整数x,y,z,请把这三个数由小到大输出。</p>\n</blockquote>\n<p>程序设计:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x 与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。</p>\n<h3 id=\"程序十六\"><a href=\"#程序十六\" class=\"headerlink\" title=\"程序十六\"></a>程序十六</h3><blockquote>\n<p>输出9*9口诀。</p>\n</blockquote>\n<p>程序设计:程序分析:分行与列考虑,共9行9列,i 控制行,j 控制列。</p>\n"},{"title":"新的开始","date":"2016-07-21T14:58:27.000Z","_content":"\n”Imagine, if you’d had a vision and worked at it, jut a little bit every day, what might have you accomplished?”\n”When we multiply tiny pieces of time with small increments of daily effort, we too will find we can accomplish magnificent things! “\n\n>回首向来萧瑟处,也无风雨也无晴\n","source":"_posts/回首向来萧瑟萧瑟处,也无风雨也无晴——新的开始.md","raw":"---\ntitle: 新的开始\ndate: 2016-07-21 22:58:27\ncategories: 感想\ntags: [生活,感想]\n---\n\n”Imagine, if you’d had a vision and worked at it, jut a little bit every day, what might have you accomplished?”\n”When we multiply tiny pieces of time with small increments of daily effort, we too will find we can accomplish magnificent things! “\n\n>回首向来萧瑟处,也无风雨也无晴\n","slug":"回首向来萧瑟萧瑟处,也无风雨也无晴——新的开始","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaiec000o3sasox0rgx0l","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><p>”Imagine, if you’d had a vision and worked at it, jut a little bit every day, what might have you accomplished?”<br>”When we multiply tiny pieces of time with small increments of daily effort, we too will find we can accomplish magnificent things! “</p>\n<blockquote>\n<p>回首向来萧瑟处,也无风雨也无晴</p>\n</blockquote>\n","excerpt":"","more":"<p>”Imagine, if you’d had a vision and worked at it, jut a little bit every day, what might have you accomplished?”<br>”When we multiply tiny pieces of time with small increments of daily effort, we too will find we can accomplish magnificent things! “</p>\n<blockquote>\n<p>回首向来萧瑟处,也无风雨也无晴</p>\n</blockquote>\n"},{"title":"关于session序列化异常","subtitle":"java.io.WriteAbortedException","date":"2016-08-02T13:56:21.000Z","_content":"\n### 1.在tomcat下部署的SSH2项目\n``` bash\n严重: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\njava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n\nCaused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n\n严重: Exception loading sessions from persistent storage\njava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n\nCaused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n```\n\n\n### 2.分析\n回顾session销毁的主要情况\n* 超时,超过30min\n* 服务器非正常关闭\n* 调用invalidate()方法\n\n分析1:运行tomcat下面的 ssh项目,启动,打开某页面(让session起作用),关闭服务器;再重新启动(第二次启动),控制台抛出异常[NotSerializableException]\n分析2:运行tomcat下面的 ssh项目,启动,直接强行关闭服务器;再重新启动(第二次启动),不会产生异常\n\n### 3.原因\n1.tomcat停止时,会在下面的目录中\n``` bash\n[.metadata\\.me_tcat7\\work\\Catalina\\localhost\\项目]\n```\n保存session资源,然后再在重启tomcat服务器时,服务器会恢复该session资源,由于项目在配置实体对象时,未实现序列化[NotSerializable]操作,启动过程中就会出现未序列化的异常[NotSerializableException]\n2.若是【正常关闭tomcat服务器】的情况下,session不销毁并完成序列化,session会保存在硬盘下。\n\n### 4.解决\n* 非正常关闭\n\n* 不保存session,在server.xml中Context下配置Manager:\n``` bash\n<Manager className=\"org.apache.catalina.session.PersistentManager\" saveOnRestart=\"false\">\n <Store className=\"org.apache.catalina.session.FileStore\"/>\n</Manager>\n```\n\n* 给实体类对象实现Serializable接口\n``` bash\npublic class Category implements Serializable{\n ...\n}\n```\n","source":"_posts/关于java-io-WriteAbortedException.md","raw":"---\ntitle: 关于session序列化异常\nsubtitle: java.io.WriteAbortedException\ndate: 2016-08-02 21:56:21\ncategories: 编程\ntags: [Java,Exception]\n---\n\n### 1.在tomcat下部署的SSH2项目\n``` bash\n严重: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\njava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n\nCaused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n\n严重: Exception loading sessions from persistent storage\njava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n\nCaused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category\n```\n\n\n### 2.分析\n回顾session销毁的主要情况\n* 超时,超过30min\n* 服务器非正常关闭\n* 调用invalidate()方法\n\n分析1:运行tomcat下面的 ssh项目,启动,打开某页面(让session起作用),关闭服务器;再重新启动(第二次启动),控制台抛出异常[NotSerializableException]\n分析2:运行tomcat下面的 ssh项目,启动,直接强行关闭服务器;再重新启动(第二次启动),不会产生异常\n\n### 3.原因\n1.tomcat停止时,会在下面的目录中\n``` bash\n[.metadata\\.me_tcat7\\work\\Catalina\\localhost\\项目]\n```\n保存session资源,然后再在重启tomcat服务器时,服务器会恢复该session资源,由于项目在配置实体对象时,未实现序列化[NotSerializable]操作,启动过程中就会出现未序列化的异常[NotSerializableException]\n2.若是【正常关闭tomcat服务器】的情况下,session不销毁并完成序列化,session会保存在硬盘下。\n\n### 4.解决\n* 非正常关闭\n\n* 不保存session,在server.xml中Context下配置Manager:\n``` bash\n<Manager className=\"org.apache.catalina.session.PersistentManager\" saveOnRestart=\"false\">\n <Store className=\"org.apache.catalina.session.FileStore\"/>\n</Manager>\n```\n\n* 给实体类对象实现Serializable接口\n``` bash\npublic class Category implements Serializable{\n ...\n}\n```\n","slug":"关于java-io-WriteAbortedException","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaief000r3saskrs25dvu","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"1-在tomcat下部署的SSH2项目\"><a href=\"#1-在tomcat下部署的SSH2项目\" class=\"headerlink\" title=\"1.在tomcat下部署的SSH2项目\"></a>1.在tomcat下部署的SSH2项目</h3><figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\">严重: IOException <span class=\"keyword\">while</span> loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\">java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\"></div><div class=\"line\">Caused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\"></div><div class=\"line\">严重: Exception loading sessions from persistent storage</div><div class=\"line\">java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\"></div><div class=\"line\">Caused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div></pre></td></tr></table></figure>\n<h3 id=\"2-分析\"><a href=\"#2-分析\" class=\"headerlink\" title=\"2.分析\"></a>2.分析</h3><p>回顾session销毁的主要情况</p>\n<ul>\n<li>超时,超过30min</li>\n<li>服务器非正常关闭</li>\n<li>调用invalidate()方法</li>\n</ul>\n<p>分析1:运行tomcat下面的 ssh项目,启动,打开某页面(让session起作用),关闭服务器;再重新启动(第二次启动),控制台抛出异常[NotSerializableException]<br>分析2:运行tomcat下面的 ssh项目,启动,直接强行关闭服务器;再重新启动(第二次启动),不会产生异常</p>\n<h3 id=\"3-原因\"><a href=\"#3-原因\" class=\"headerlink\" title=\"3.原因\"></a>3.原因</h3><p>1.tomcat停止时,会在下面的目录中<br><figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">[.metadata\\.me_tcat7\\work\\Catalina\\localhost\\项目]</div></pre></td></tr></table></figure></p>\n<p>保存session资源,然后再在重启tomcat服务器时,服务器会恢复该session资源,由于项目在配置实体对象时,未实现序列化[NotSerializable]操作,启动过程中就会出现未序列化的异常[NotSerializableException]<br>2.若是【正常关闭tomcat服务器】的情况下,session不销毁并完成序列化,session会保存在硬盘下。</p>\n<h3 id=\"4-解决\"><a href=\"#4-解决\" class=\"headerlink\" title=\"4.解决\"></a>4.解决</h3><ul>\n<li><p>非正常关闭</p>\n</li>\n<li><p>不保存session,在server.xml中Context下配置Manager:</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><Manager className=<span class=\"string\">\"org.apache.catalina.session.PersistentManager\"</span> saveOnRestart=<span class=\"string\">\"false\"</span>></div><div class=\"line\"> <Store className=<span class=\"string\">\"org.apache.catalina.session.FileStore\"</span>/></div><div class=\"line\"></Manager></div></pre></td></tr></table></figure>\n</li>\n<li><p>给实体类对象实现Serializable接口</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\">public class Category implements Serializable{</div><div class=\"line\"> ...</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n","excerpt":"","more":"<h3 id=\"1-在tomcat下部署的SSH2项目\"><a href=\"#1-在tomcat下部署的SSH2项目\" class=\"headerlink\" title=\"1.在tomcat下部署的SSH2项目\"></a>1.在tomcat下部署的SSH2项目</h3><figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\">严重: IOException <span class=\"keyword\">while</span> loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\">java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\"></div><div class=\"line\">Caused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\"></div><div class=\"line\">严重: Exception loading sessions from persistent storage</div><div class=\"line\">java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div><div class=\"line\"></div><div class=\"line\">Caused by: java.io.NotSerializableException: com.yanlin.shop.category.vo.Category</div></pre></td></tr></table></figure>\n<h3 id=\"2-分析\"><a href=\"#2-分析\" class=\"headerlink\" title=\"2.分析\"></a>2.分析</h3><p>回顾session销毁的主要情况</p>\n<ul>\n<li>超时,超过30min</li>\n<li>服务器非正常关闭</li>\n<li>调用invalidate()方法</li>\n</ul>\n<p>分析1:运行tomcat下面的 ssh项目,启动,打开某页面(让session起作用),关闭服务器;再重新启动(第二次启动),控制台抛出异常[NotSerializableException]<br>分析2:运行tomcat下面的 ssh项目,启动,直接强行关闭服务器;再重新启动(第二次启动),不会产生异常</p>\n<h3 id=\"3-原因\"><a href=\"#3-原因\" class=\"headerlink\" title=\"3.原因\"></a>3.原因</h3><p>1.tomcat停止时,会在下面的目录中<br><figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">[.metadata\\.me_tcat7\\work\\Catalina\\localhost\\项目]</div></pre></td></tr></table></figure></p>\n<p>保存session资源,然后再在重启tomcat服务器时,服务器会恢复该session资源,由于项目在配置实体对象时,未实现序列化[NotSerializable]操作,启动过程中就会出现未序列化的异常[NotSerializableException]<br>2.若是【正常关闭tomcat服务器】的情况下,session不销毁并完成序列化,session会保存在硬盘下。</p>\n<h3 id=\"4-解决\"><a href=\"#4-解决\" class=\"headerlink\" title=\"4.解决\"></a>4.解决</h3><ul>\n<li><p>非正常关闭</p>\n</li>\n<li><p>不保存session,在server.xml中Context下配置Manager:</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><Manager className=<span class=\"string\">\"org.apache.catalina.session.PersistentManager\"</span> saveOnRestart=<span class=\"string\">\"false\"</span>></div><div class=\"line\"> <Store className=<span class=\"string\">\"org.apache.catalina.session.FileStore\"</span>/></div><div class=\"line\"></Manager></div></pre></td></tr></table></figure>\n</li>\n<li><p>给实体类对象实现Serializable接口</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\">public class Category implements Serializable{</div><div class=\"line\"> ...</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n"},{"title":"条件查询和分页原理(一)","date":"2016-08-21T16:33:54.000Z","_content":"\n\n### 条件查询--准备\n\n#### 条件查询的SQL语句:\n\n比如下面的语句,其中条件一表示columnName1关键字查询,条件二表示columnName2取值大于xxx\n\n``` sql\nselect t.* from tableName t where t.columnName1 like '%M%' and columnName2 > xxx and ...\n```\n\n#### 实现通用的sql语句的查询\n\n实现通用的sql语句的查询需要解决两部分的封装:\n- 一部分是预编译语句的封装,比如:\n\n``` java\nString sql = \"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\";\n```\n- 一部分是参数的封装\n``` java\nObject[] params = {t.columnName1,t.columnName2};\n```\n### 定义接口的规范\n\n``` java\n/**\n * 查询\n * @author bubblelin\n *\n */\npublic interface IQuery {\n\n\t/**\n\t * 查询条件\n\t * @return\n\t */\n\tString getQuerySql();\n\n\t/**\n\t * 查询条件的参数\n\t * @return\n\t */\n\tList<Object> getParameters();\n\n}\n```\n\n### 实现接口(核心部分)\n\n``` java\n/**\n * 高级查询的实体\n *\n * @author bubblelin\n * @param <T>\n *\n */\npublic class QueryObject implements IQuery {\n\n\tprivate List<Object> parameters = new ArrayList<>();\n\tprivate List<Object> conditions = new ArrayList<>();\n\tprivate Map<String, String> orderByMap = new LinkedHashMap<>();\n\n\tpublic String getQuerySql() {\n\t\t//清空集合\n\t\tthis.parameters.clear();\n\t\tthis.conditions.clear();\n\t\t// \"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\"\n\t\tStringBuilder sb = new StringBuilder(200);\n //调用自定义查询条件的方法\n\t\tcustomizedQuery();\n //拼接条件语句\n\t\tfor (int i = 0; i < conditions.size(); i++) {\n\t\t\tif (i == 0) {\n\t\t\t\tsb.append(\" where \");\n\t\t\t} else {\n\t\t\t\tsb.append(\" and \");\n\t\t\t}\n\t\t\tsb.append(\"(\" + conditions.get(i) + \")\");\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic List<Object> getParameters() {\n\t\treturn parameters;\n\t}\n //用于子类继承,并实现自定义的查询条件\n\tprotected void customizedQuery() {\n\t}\n //用于子类的继承,查询条件封装到conditions集合,查询参数封装到parameters集合\n\tprotected void setQueryObject(String condition, Object... parameter) {\n\t\tconditions.add(condition);\n\t\tparameters.addAll(Arrays.asList(parameter));\n\t}\n\n}\n\n```\n\n### 子类条件查询的实体\n\n``` java\n/**\n * 高级查询的实体\n * @author bubblelin\n *\n */\npublic class ProductQueryObject extends QueryObject{\n //实现getter/setter方法\n\tprivate String productName;\n\tprivate BigDecimal minSalePrice;\n\tprivate BigDecimal maxSalePrice;\n\tprivate Long dir_id;\n\tprivate String keyWord;\n\n\tprotected void customizedQuery(){\n\t\tif(StringUtils.hasLength(productName)){\n\t\t\tsuper.setQueryObject(\" productName like ? \", \"%\"+productName+\"%\");\n\t\t}\n\t\tif(minSalePrice != null){\n\t\t\tsuper.setQueryObject(\" salePrice>? \", minSalePrice);\n\t\t}\n\t\tif(maxSalePrice != null){\n\t\t\tsuper.setQueryObject(\" salePrice<? \", maxSalePrice);\n\t\t}\n\t\tif(dir_id != null && dir_id != -1){\n\t\t\tsuper.setQueryObject(\" dir_Id= ? \", dir_id);\n\t\t}\n\t\tif(StringUtils.hasLength(keyWord)){\n //一个查询条件对应两个参数,父类用`Object... parameter`接收\n\t\t\tsuper.setQueryObject(\" productName like ? or brand like ? \", \"%\"+keyWord+\"%\",\"%\"+keyWord+\"%\");\n\t\t}\n\t}\n\n```\n\n### 查询方法\n\n备注:`JdbcTemplate.executeQuery()`未数据库查询方法\n\n``` java\n/**\n * 条件查询\n */\npublic List<Product> queryProduct(IQuery qo) {\n //预编译语句的封装\n String sql = \"select * from product \" + qo.getQuerySql();\n //参数的封装\n Object[] parameters = qo.getParameters().toArray();\n //查询的方法\n return JdbcTemplate.executeQuery(sql, new productResultSetHandlerList(),\n parameters);\n}\n```\n","source":"_posts/条件查询和分页原理到底是怎么样的.md","raw":"---\ntitle: 条件查询和分页原理(一)\ndate: 2016-08-22 00:33:54\ncategories: 编程 \ntags: [Java] \n---\n\n\n### 条件查询--准备\n\n#### 条件查询的SQL语句:\n\n比如下面的语句,其中条件一表示columnName1关键字查询,条件二表示columnName2取值大于xxx\n\n``` sql\nselect t.* from tableName t where t.columnName1 like '%M%' and columnName2 > xxx and ...\n```\n\n#### 实现通用的sql语句的查询\n\n实现通用的sql语句的查询需要解决两部分的封装:\n- 一部分是预编译语句的封装,比如:\n\n``` java\nString sql = \"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\";\n```\n- 一部分是参数的封装\n``` java\nObject[] params = {t.columnName1,t.columnName2};\n```\n### 定义接口的规范\n\n``` java\n/**\n * 查询\n * @author bubblelin\n *\n */\npublic interface IQuery {\n\n\t/**\n\t * 查询条件\n\t * @return\n\t */\n\tString getQuerySql();\n\n\t/**\n\t * 查询条件的参数\n\t * @return\n\t */\n\tList<Object> getParameters();\n\n}\n```\n\n### 实现接口(核心部分)\n\n``` java\n/**\n * 高级查询的实体\n *\n * @author bubblelin\n * @param <T>\n *\n */\npublic class QueryObject implements IQuery {\n\n\tprivate List<Object> parameters = new ArrayList<>();\n\tprivate List<Object> conditions = new ArrayList<>();\n\tprivate Map<String, String> orderByMap = new LinkedHashMap<>();\n\n\tpublic String getQuerySql() {\n\t\t//清空集合\n\t\tthis.parameters.clear();\n\t\tthis.conditions.clear();\n\t\t// \"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\"\n\t\tStringBuilder sb = new StringBuilder(200);\n //调用自定义查询条件的方法\n\t\tcustomizedQuery();\n //拼接条件语句\n\t\tfor (int i = 0; i < conditions.size(); i++) {\n\t\t\tif (i == 0) {\n\t\t\t\tsb.append(\" where \");\n\t\t\t} else {\n\t\t\t\tsb.append(\" and \");\n\t\t\t}\n\t\t\tsb.append(\"(\" + conditions.get(i) + \")\");\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tpublic List<Object> getParameters() {\n\t\treturn parameters;\n\t}\n //用于子类继承,并实现自定义的查询条件\n\tprotected void customizedQuery() {\n\t}\n //用于子类的继承,查询条件封装到conditions集合,查询参数封装到parameters集合\n\tprotected void setQueryObject(String condition, Object... parameter) {\n\t\tconditions.add(condition);\n\t\tparameters.addAll(Arrays.asList(parameter));\n\t}\n\n}\n\n```\n\n### 子类条件查询的实体\n\n``` java\n/**\n * 高级查询的实体\n * @author bubblelin\n *\n */\npublic class ProductQueryObject extends QueryObject{\n //实现getter/setter方法\n\tprivate String productName;\n\tprivate BigDecimal minSalePrice;\n\tprivate BigDecimal maxSalePrice;\n\tprivate Long dir_id;\n\tprivate String keyWord;\n\n\tprotected void customizedQuery(){\n\t\tif(StringUtils.hasLength(productName)){\n\t\t\tsuper.setQueryObject(\" productName like ? \", \"%\"+productName+\"%\");\n\t\t}\n\t\tif(minSalePrice != null){\n\t\t\tsuper.setQueryObject(\" salePrice>? \", minSalePrice);\n\t\t}\n\t\tif(maxSalePrice != null){\n\t\t\tsuper.setQueryObject(\" salePrice<? \", maxSalePrice);\n\t\t}\n\t\tif(dir_id != null && dir_id != -1){\n\t\t\tsuper.setQueryObject(\" dir_Id= ? \", dir_id);\n\t\t}\n\t\tif(StringUtils.hasLength(keyWord)){\n //一个查询条件对应两个参数,父类用`Object... parameter`接收\n\t\t\tsuper.setQueryObject(\" productName like ? or brand like ? \", \"%\"+keyWord+\"%\",\"%\"+keyWord+\"%\");\n\t\t}\n\t}\n\n```\n\n### 查询方法\n\n备注:`JdbcTemplate.executeQuery()`未数据库查询方法\n\n``` java\n/**\n * 条件查询\n */\npublic List<Product> queryProduct(IQuery qo) {\n //预编译语句的封装\n String sql = \"select * from product \" + qo.getQuerySql();\n //参数的封装\n Object[] parameters = qo.getParameters().toArray();\n //查询的方法\n return JdbcTemplate.executeQuery(sql, new productResultSetHandlerList(),\n parameters);\n}\n```\n","slug":"条件查询和分页原理到底是怎么样的","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaiej000w3sasn1lokdkr","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"条件查询–准备\"><a href=\"#条件查询–准备\" class=\"headerlink\" title=\"条件查询–准备\"></a>条件查询–准备</h3><h4 id=\"条件查询的SQL语句:\"><a href=\"#条件查询的SQL语句:\" class=\"headerlink\" title=\"条件查询的SQL语句:\"></a>条件查询的SQL语句:</h4><p>比如下面的语句,其中条件一表示columnName1关键字查询,条件二表示columnName2取值大于xxx</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span> t.* <span class=\"keyword\">from</span> tableName t <span class=\"keyword\">where</span> t.columnName1 <span class=\"keyword\">like</span> <span class=\"string\">'%M%'</span> <span class=\"keyword\">and</span> columnName2 > xxx <span class=\"keyword\">and</span> ...</div></pre></td></tr></table></figure>\n<h4 id=\"实现通用的sql语句的查询\"><a href=\"#实现通用的sql语句的查询\" class=\"headerlink\" title=\"实现通用的sql语句的查询\"></a>实现通用的sql语句的查询</h4><p>实现通用的sql语句的查询需要解决两部分的封装:</p>\n<ul>\n<li>一部分是预编译语句的封装,比如:</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">String sql = <span class=\"string\">\"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\"</span>;</div></pre></td></tr></table></figure>\n<ul>\n<li>一部分是参数的封装<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">Object[] params = {t.columnName1,t.columnName2};</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"定义接口的规范\"><a href=\"#定义接口的规范\" class=\"headerlink\" title=\"定义接口的规范\"></a>定义接口的规范</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</span></div><div class=\"line\"> * 查询</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> *</div><div class=\"line\"> */</div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">interface</span> <span class=\"title\">IQuery</span> </span>{</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"comment\">/**</span></div><div class=\"line\">\t * 查询条件</div><div class=\"line\">\t * <span class=\"doctag\">@return</span></div><div class=\"line\">\t */</div><div class=\"line\">\t<span class=\"function\">String <span class=\"title\">getQuerySql</span><span class=\"params\">()</span></span>;</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"comment\">/**</span></div><div class=\"line\">\t * 查询条件的参数</div><div class=\"line\">\t * <span class=\"doctag\">@return</span></div><div class=\"line\">\t */</div><div class=\"line\">\t<span class=\"function\">List<Object> <span class=\"title\">getParameters</span><span class=\"params\">()</span></span>;</div><div class=\"line\"></div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"实现接口-核心部分\"><a href=\"#实现接口-核心部分\" class=\"headerlink\" title=\"实现接口(核心部分)\"></a>实现接口(核心部分)</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div><div class=\"line\">27</div><div class=\"line\">28</div><div class=\"line\">29</div><div class=\"line\">30</div><div class=\"line\">31</div><div class=\"line\">32</div><div class=\"line\">33</div><div class=\"line\">34</div><div class=\"line\">35</div><div class=\"line\">36</div><div class=\"line\">37</div><div class=\"line\">38</div><div class=\"line\">39</div><div class=\"line\">40</div><div class=\"line\">41</div><div class=\"line\">42</div><div class=\"line\">43</div><div class=\"line\">44</div><div class=\"line\">45</div><div class=\"line\">46</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</span></div><div class=\"line\"> * 高级查询的实体</div><div class=\"line\"> *</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> * <span class=\"doctag\">@param</span> <T></div><div class=\"line\"> *</div><div class=\"line\"> */</div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">QueryObject</span> <span class=\"keyword\">implements</span> <span class=\"title\">IQuery</span> </span>{</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"keyword\">private</span> List<Object> parameters = <span class=\"keyword\">new</span> ArrayList<>();</div><div class=\"line\">\t<span class=\"keyword\">private</span> List<Object> conditions = <span class=\"keyword\">new</span> ArrayList<>();</div><div class=\"line\">\t<span class=\"keyword\">private</span> Map<String, String> orderByMap = <span class=\"keyword\">new</span> LinkedHashMap<>();</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">getQuerySql</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t\t<span class=\"comment\">//清空集合</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.parameters.clear();</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.conditions.clear();</div><div class=\"line\">\t\t<span class=\"comment\">// \"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\"</span></div><div class=\"line\">\t\tStringBuilder sb = <span class=\"keyword\">new</span> StringBuilder(<span class=\"number\">200</span>);</div><div class=\"line\"> <span class=\"comment\">//调用自定义查询条件的方法</span></div><div class=\"line\">\t\tcustomizedQuery();</div><div class=\"line\"> <span class=\"comment\">//拼接条件语句</span></div><div class=\"line\">\t\t<span class=\"keyword\">for</span> (<span class=\"keyword\">int</span> i = <span class=\"number\">0</span>; i < conditions.size(); i++) {</div><div class=\"line\">\t\t\t<span class=\"keyword\">if</span> (i == <span class=\"number\">0</span>) {</div><div class=\"line\">\t\t\t\tsb.append(<span class=\"string\">\" where \"</span>);</div><div class=\"line\">\t\t\t} <span class=\"keyword\">else</span> {</div><div class=\"line\">\t\t\t\tsb.append(<span class=\"string\">\" and \"</span>);</div><div class=\"line\">\t\t\t}</div><div class=\"line\">\t\t\tsb.append(<span class=\"string\">\"(\"</span> + conditions.get(i) + <span class=\"string\">\")\"</span>);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">return</span> sb.toString();</div><div class=\"line\">\t}</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> List<Object> <span class=\"title\">getParameters</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t\t<span class=\"keyword\">return</span> parameters;</div><div class=\"line\">\t}</div><div class=\"line\"> <span class=\"comment\">//用于子类继承,并实现自定义的查询条件</span></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">protected</span> <span class=\"keyword\">void</span> <span class=\"title\">customizedQuery</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t}</div><div class=\"line\"> <span class=\"comment\">//用于子类的继承,查询条件封装到conditions集合,查询参数封装到parameters集合</span></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">protected</span> <span class=\"keyword\">void</span> <span class=\"title\">setQueryObject</span><span class=\"params\">(String condition, Object... parameter)</span> </span>{</div><div class=\"line\">\t\tconditions.add(condition);</div><div class=\"line\">\t\tparameters.addAll(Arrays.asList(parameter));</div><div class=\"line\">\t}</div><div class=\"line\"></div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"子类条件查询的实体\"><a href=\"#子类条件查询的实体\" class=\"headerlink\" title=\"子类条件查询的实体\"></a>子类条件查询的实体</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div><div class=\"line\">27</div><div class=\"line\">28</div><div class=\"line\">29</div><div class=\"line\">30</div><div class=\"line\">31</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</span></div><div class=\"line\"> * 高级查询的实体</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> *</div><div class=\"line\"> */</div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">ProductQueryObject</span> <span class=\"keyword\">extends</span> <span class=\"title\">QueryObject</span></span>{</div><div class=\"line\"> <span class=\"comment\">//实现getter/setter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> String productName;</div><div class=\"line\">\t<span class=\"keyword\">private</span> BigDecimal minSalePrice;</div><div class=\"line\">\t<span class=\"keyword\">private</span> BigDecimal maxSalePrice;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Long dir_id;</div><div class=\"line\">\t<span class=\"keyword\">private</span> String keyWord;</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">protected</span> <span class=\"keyword\">void</span> <span class=\"title\">customizedQuery</span><span class=\"params\">()</span></span>{</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(StringUtils.hasLength(productName)){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" productName like ? \"</span>, <span class=\"string\">\"%\"</span>+productName+<span class=\"string\">\"%\"</span>);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(minSalePrice != <span class=\"keyword\">null</span>){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" salePrice>? \"</span>, minSalePrice);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(maxSalePrice != <span class=\"keyword\">null</span>){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" salePrice<? \"</span>, maxSalePrice);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(dir_id != <span class=\"keyword\">null</span> && dir_id != -<span class=\"number\">1</span>){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" dir_Id= ? \"</span>, dir_id);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(StringUtils.hasLength(keyWord)){</div><div class=\"line\"> <span class=\"comment\">//一个查询条件对应两个参数,父类用`Object... parameter`接收</span></div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" productName like ? or brand like ? \"</span>, <span class=\"string\">\"%\"</span>+keyWord+<span class=\"string\">\"%\"</span>,<span class=\"string\">\"%\"</span>+keyWord+<span class=\"string\">\"%\"</span>);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t}</div></pre></td></tr></table></figure>\n<h3 id=\"查询方法\"><a href=\"#查询方法\" class=\"headerlink\" title=\"查询方法\"></a>查询方法</h3><p>备注:<code>JdbcTemplate.executeQuery()</code>未数据库查询方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</span></div><div class=\"line\"> * 条件查询</div><div class=\"line\"> */</div><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> List<Product> <span class=\"title\">queryProduct</span><span class=\"params\">(IQuery qo)</span> </span>{</div><div class=\"line\"> <span class=\"comment\">//预编译语句的封装</span></div><div class=\"line\"> String sql = <span class=\"string\">\"select * from product \"</span> + qo.getQuerySql();</div><div class=\"line\"> <span class=\"comment\">//参数的封装</span></div><div class=\"line\"> Object[] parameters = qo.getParameters().toArray();</div><div class=\"line\"> <span class=\"comment\">//查询的方法</span></div><div class=\"line\"> <span class=\"keyword\">return</span> JdbcTemplate.executeQuery(sql, <span class=\"keyword\">new</span> productResultSetHandlerList(),</div><div class=\"line\"> parameters);</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n","excerpt":"","more":"<h3 id=\"条件查询–准备\"><a href=\"#条件查询–准备\" class=\"headerlink\" title=\"条件查询–准备\"></a>条件查询–准备</h3><h4 id=\"条件查询的SQL语句:\"><a href=\"#条件查询的SQL语句:\" class=\"headerlink\" title=\"条件查询的SQL语句:\"></a>条件查询的SQL语句:</h4><p>比如下面的语句,其中条件一表示columnName1关键字查询,条件二表示columnName2取值大于xxx</p>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span> t.* <span class=\"keyword\">from</span> tableName t <span class=\"keyword\">where</span> t.columnName1 <span class=\"keyword\">like</span> <span class=\"string\">'%M%'</span> <span class=\"keyword\">and</span> columnName2 > xxx <span class=\"keyword\">and</span> ...</div></pre></td></tr></table></figure>\n<h4 id=\"实现通用的sql语句的查询\"><a href=\"#实现通用的sql语句的查询\" class=\"headerlink\" title=\"实现通用的sql语句的查询\"></a>实现通用的sql语句的查询</h4><p>实现通用的sql语句的查询需要解决两部分的封装:</p>\n<ul>\n<li>一部分是预编译语句的封装,比如:</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">String sql = <span class=\"string\">\"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\"</span>;</div></pre></td></tr></table></figure>\n<ul>\n<li>一部分是参数的封装<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">Object[] params = {t.columnName1,t.columnName2};</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"定义接口的规范\"><a href=\"#定义接口的规范\" class=\"headerlink\" title=\"定义接口的规范\"></a>定义接口的规范</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</div><div class=\"line\"> * 查询</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> *</div><div class=\"line\"> */</span></div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">interface</span> <span class=\"title\">IQuery</span> </span>{</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"comment\">/**</div><div class=\"line\">\t * 查询条件</div><div class=\"line\">\t * <span class=\"doctag\">@return</span></div><div class=\"line\">\t */</span></div><div class=\"line\">\t<span class=\"function\">String <span class=\"title\">getQuerySql</span><span class=\"params\">()</span></span>;</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"comment\">/**</div><div class=\"line\">\t * 查询条件的参数</div><div class=\"line\">\t * <span class=\"doctag\">@return</span></div><div class=\"line\">\t */</span></div><div class=\"line\">\t<span class=\"function\">List<Object> <span class=\"title\">getParameters</span><span class=\"params\">()</span></span>;</div><div class=\"line\"></div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"实现接口-核心部分\"><a href=\"#实现接口-核心部分\" class=\"headerlink\" title=\"实现接口(核心部分)\"></a>实现接口(核心部分)</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div><div class=\"line\">27</div><div class=\"line\">28</div><div class=\"line\">29</div><div class=\"line\">30</div><div class=\"line\">31</div><div class=\"line\">32</div><div class=\"line\">33</div><div class=\"line\">34</div><div class=\"line\">35</div><div class=\"line\">36</div><div class=\"line\">37</div><div class=\"line\">38</div><div class=\"line\">39</div><div class=\"line\">40</div><div class=\"line\">41</div><div class=\"line\">42</div><div class=\"line\">43</div><div class=\"line\">44</div><div class=\"line\">45</div><div class=\"line\">46</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</div><div class=\"line\"> * 高级查询的实体</div><div class=\"line\"> *</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> * <span class=\"doctag\">@param</span> <T></div><div class=\"line\"> *</div><div class=\"line\"> */</span></div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">QueryObject</span> <span class=\"keyword\">implements</span> <span class=\"title\">IQuery</span> </span>{</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"keyword\">private</span> List<Object> parameters = <span class=\"keyword\">new</span> ArrayList<>();</div><div class=\"line\">\t<span class=\"keyword\">private</span> List<Object> conditions = <span class=\"keyword\">new</span> ArrayList<>();</div><div class=\"line\">\t<span class=\"keyword\">private</span> Map<String, String> orderByMap = <span class=\"keyword\">new</span> LinkedHashMap<>();</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">getQuerySql</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t\t<span class=\"comment\">//清空集合</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.parameters.clear();</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.conditions.clear();</div><div class=\"line\">\t\t<span class=\"comment\">// \"select t.* from tableName t where t.columnName1 like ? and columnName2 > ?\"</span></div><div class=\"line\">\t\tStringBuilder sb = <span class=\"keyword\">new</span> StringBuilder(<span class=\"number\">200</span>);</div><div class=\"line\"> <span class=\"comment\">//调用自定义查询条件的方法</span></div><div class=\"line\">\t\tcustomizedQuery();</div><div class=\"line\"> <span class=\"comment\">//拼接条件语句</span></div><div class=\"line\">\t\t<span class=\"keyword\">for</span> (<span class=\"keyword\">int</span> i = <span class=\"number\">0</span>; i < conditions.size(); i++) {</div><div class=\"line\">\t\t\t<span class=\"keyword\">if</span> (i == <span class=\"number\">0</span>) {</div><div class=\"line\">\t\t\t\tsb.append(<span class=\"string\">\" where \"</span>);</div><div class=\"line\">\t\t\t} <span class=\"keyword\">else</span> {</div><div class=\"line\">\t\t\t\tsb.append(<span class=\"string\">\" and \"</span>);</div><div class=\"line\">\t\t\t}</div><div class=\"line\">\t\t\tsb.append(<span class=\"string\">\"(\"</span> + conditions.get(i) + <span class=\"string\">\")\"</span>);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">return</span> sb.toString();</div><div class=\"line\">\t}</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> List<Object> <span class=\"title\">getParameters</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t\t<span class=\"keyword\">return</span> parameters;</div><div class=\"line\">\t}</div><div class=\"line\"> <span class=\"comment\">//用于子类继承,并实现自定义的查询条件</span></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">protected</span> <span class=\"keyword\">void</span> <span class=\"title\">customizedQuery</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t}</div><div class=\"line\"> <span class=\"comment\">//用于子类的继承,查询条件封装到conditions集合,查询参数封装到parameters集合</span></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">protected</span> <span class=\"keyword\">void</span> <span class=\"title\">setQueryObject</span><span class=\"params\">(String condition, Object... parameter)</span> </span>{</div><div class=\"line\">\t\tconditions.add(condition);</div><div class=\"line\">\t\tparameters.addAll(Arrays.asList(parameter));</div><div class=\"line\">\t}</div><div class=\"line\"></div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"子类条件查询的实体\"><a href=\"#子类条件查询的实体\" class=\"headerlink\" title=\"子类条件查询的实体\"></a>子类条件查询的实体</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div><div class=\"line\">27</div><div class=\"line\">28</div><div class=\"line\">29</div><div class=\"line\">30</div><div class=\"line\">31</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</div><div class=\"line\"> * 高级查询的实体</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> *</div><div class=\"line\"> */</span></div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">ProductQueryObject</span> <span class=\"keyword\">extends</span> <span class=\"title\">QueryObject</span></span>{</div><div class=\"line\"> <span class=\"comment\">//实现getter/setter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> String productName;</div><div class=\"line\">\t<span class=\"keyword\">private</span> BigDecimal minSalePrice;</div><div class=\"line\">\t<span class=\"keyword\">private</span> BigDecimal maxSalePrice;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Long dir_id;</div><div class=\"line\">\t<span class=\"keyword\">private</span> String keyWord;</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">protected</span> <span class=\"keyword\">void</span> <span class=\"title\">customizedQuery</span><span class=\"params\">()</span></span>{</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(StringUtils.hasLength(productName)){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" productName like ? \"</span>, <span class=\"string\">\"%\"</span>+productName+<span class=\"string\">\"%\"</span>);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(minSalePrice != <span class=\"keyword\">null</span>){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" salePrice>? \"</span>, minSalePrice);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(maxSalePrice != <span class=\"keyword\">null</span>){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" salePrice<? \"</span>, maxSalePrice);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(dir_id != <span class=\"keyword\">null</span> && dir_id != -<span class=\"number\">1</span>){</div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" dir_Id= ? \"</span>, dir_id);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t\t<span class=\"keyword\">if</span>(StringUtils.hasLength(keyWord)){</div><div class=\"line\"> <span class=\"comment\">//一个查询条件对应两个参数,父类用`Object... parameter`接收</span></div><div class=\"line\">\t\t\t<span class=\"keyword\">super</span>.setQueryObject(<span class=\"string\">\" productName like ? or brand like ? \"</span>, <span class=\"string\">\"%\"</span>+keyWord+<span class=\"string\">\"%\"</span>,<span class=\"string\">\"%\"</span>+keyWord+<span class=\"string\">\"%\"</span>);</div><div class=\"line\">\t\t}</div><div class=\"line\">\t}</div></pre></td></tr></table></figure>\n<h3 id=\"查询方法\"><a href=\"#查询方法\" class=\"headerlink\" title=\"查询方法\"></a>查询方法</h3><p>备注:<code>JdbcTemplate.executeQuery()</code>未数据库查询方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</div><div class=\"line\"> * 条件查询</div><div class=\"line\"> */</span></div><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> List<Product> <span class=\"title\">queryProduct</span><span class=\"params\">(IQuery qo)</span> </span>{</div><div class=\"line\"> <span class=\"comment\">//预编译语句的封装</span></div><div class=\"line\"> String sql = <span class=\"string\">\"select * from product \"</span> + qo.getQuerySql();</div><div class=\"line\"> <span class=\"comment\">//参数的封装</span></div><div class=\"line\"> Object[] parameters = qo.getParameters().toArray();</div><div class=\"line\"> <span class=\"comment\">//查询的方法</span></div><div class=\"line\"> <span class=\"keyword\">return</span> JdbcTemplate.executeQuery(sql, <span class=\"keyword\">new</span> productResultSetHandlerList(),</div><div class=\"line\"> parameters);</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n"},{"title":"简单实例之文件上传(一),利用commons-fileupload","date":"2016-08-10T15:04:18.000Z","_content":"\n### 必须的准备工作\n\n- 文件上传的表单提交方式须用POST,因为GET方式适用于url,若传输数据大小不能超过2KB\n- 须有文件上传控件:\n``` html\n<input type=”file” name=”filename”/>\n```\n- 表单使用二进制编码方式\n``` html\n<form ... enctype=\"multipart/form-data\" .../>\n```\n- 备注:在servlet中获取上传文件的注意\n>当表单使用二进制编码之后,此时再也不能直接使用`request.getParameter`方法来获取请求参数了.因为`request.getParameter`就仅仅只能获取`application/x-www-form-urlencoded`编码方式的参数.\n\n### 环境准备\n\n- 文件上传依赖的jar包\n``` bash\ncommons-fileupload-1.2.2.jar\ncommons-io-1.4.jar\n```\n- 下载地址\ncommons-fileupload:http://commons.apache.org/fileupload/\ncommons-io:http://commons.apache.org/io/\n\n### 代码实现\n\n1. 检查文件上传的请求:请求方式是否是POST,context-type是否是multipart/form-data\n``` java\nboolean isMultipart = ServletFileUpload.isMultipartContent(request);\n```\n2. 创建一个FileItemd的工厂对象,目的是创建FileItem对象\n``` java\nFileItemFactory factory = new DiskFileItemFactory();\n```\n3. 创建文件上传处理器\n``` java\nServletFileUpload upload = new ServletFileUpload(factory);\n```\n4. 文件上传处理器解析请求,解析请求需要抛出FileUploadException\n``` java\nList<FileItem> items = upload.parseRequest(req);\n```\n5. 处理器解析出来请求包含:普通表单item和文件表单item\n``` java\nIterator<FileItem> it = items.iterator();\nwhile(it.hasNext()){\n\tFileItem fileItem = it.next();\n\tif(fileItem.isFormField()){\n\t\t//普通表单item,获取用户在控件中个输入的value\n\t\tSystem.out.println(fileItem.getString(\"UTF-8\"));\n\t}else{\n\t\t//文件表单item,保存到服务器磁盘upload文件夹中\n\t\tString dir = super.getServletContext().getRealPath(\"/upload\");\n\t\tString randomFileName = UUID.randomUUID().toString()+\".\"+FilenameUtils.getExtension(fileItem.getName());\n //保存到磁盘需要抛出异常,此处仅标明\n\t\tfileItem.write(new File(dir, randomFileName));\n\t}\n}\n```\n\n6. jsp页面\n``` html\n<form action=\"/upload\" method=\"post\" enctype=\"multipart/form-data\">\n\t账户:\n\t<input type=\"text\" name=\"username\"/><br>\n\t邮箱:\n\t<input type=\"text\" name=\"email\"/><br>\n\t头像:\n\t<input type=\"file\" name=\"headImg\"/><br>\n\t<input type=\"submit\" value=\"保存\"/>\n</form>\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n``` bash\n```\n","source":"_posts/文件上传(一).md","raw":"---\ntitle: 简单实例之文件上传(一),利用commons-fileupload\ndate: 2016-08-10 23:04:18\ncategories: 编程\ntags: [Java]\n---\n\n### 必须的准备工作\n\n- 文件上传的表单提交方式须用POST,因为GET方式适用于url,若传输数据大小不能超过2KB\n- 须有文件上传控件:\n``` html\n<input type=”file” name=”filename”/>\n```\n- 表单使用二进制编码方式\n``` html\n<form ... enctype=\"multipart/form-data\" .../>\n```\n- 备注:在servlet中获取上传文件的注意\n>当表单使用二进制编码之后,此时再也不能直接使用`request.getParameter`方法来获取请求参数了.因为`request.getParameter`就仅仅只能获取`application/x-www-form-urlencoded`编码方式的参数.\n\n### 环境准备\n\n- 文件上传依赖的jar包\n``` bash\ncommons-fileupload-1.2.2.jar\ncommons-io-1.4.jar\n```\n- 下载地址\ncommons-fileupload:http://commons.apache.org/fileupload/\ncommons-io:http://commons.apache.org/io/\n\n### 代码实现\n\n1. 检查文件上传的请求:请求方式是否是POST,context-type是否是multipart/form-data\n``` java\nboolean isMultipart = ServletFileUpload.isMultipartContent(request);\n```\n2. 创建一个FileItemd的工厂对象,目的是创建FileItem对象\n``` java\nFileItemFactory factory = new DiskFileItemFactory();\n```\n3. 创建文件上传处理器\n``` java\nServletFileUpload upload = new ServletFileUpload(factory);\n```\n4. 文件上传处理器解析请求,解析请求需要抛出FileUploadException\n``` java\nList<FileItem> items = upload.parseRequest(req);\n```\n5. 处理器解析出来请求包含:普通表单item和文件表单item\n``` java\nIterator<FileItem> it = items.iterator();\nwhile(it.hasNext()){\n\tFileItem fileItem = it.next();\n\tif(fileItem.isFormField()){\n\t\t//普通表单item,获取用户在控件中个输入的value\n\t\tSystem.out.println(fileItem.getString(\"UTF-8\"));\n\t}else{\n\t\t//文件表单item,保存到服务器磁盘upload文件夹中\n\t\tString dir = super.getServletContext().getRealPath(\"/upload\");\n\t\tString randomFileName = UUID.randomUUID().toString()+\".\"+FilenameUtils.getExtension(fileItem.getName());\n //保存到磁盘需要抛出异常,此处仅标明\n\t\tfileItem.write(new File(dir, randomFileName));\n\t}\n}\n```\n\n6. jsp页面\n``` html\n<form action=\"/upload\" method=\"post\" enctype=\"multipart/form-data\">\n\t账户:\n\t<input type=\"text\" name=\"username\"/><br>\n\t邮箱:\n\t<input type=\"text\" name=\"email\"/><br>\n\t头像:\n\t<input type=\"file\" name=\"headImg\"/><br>\n\t<input type=\"submit\" value=\"保存\"/>\n</form>\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n``` bash\n```\n","slug":"文件上传(一)","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaiem000z3sass189i4kg","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"必须的准备工作\"><a href=\"#必须的准备工作\" class=\"headerlink\" title=\"必须的准备工作\"></a>必须的准备工作</h3><ul>\n<li>文件上传的表单提交方式须用POST,因为GET方式适用于url,若传输数据大小不能超过2KB</li>\n<li><p>须有文件上传控件:</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">”file”</span> <span class=\"attr\">name</span>=<span class=\"string\">”filename”/</span>></span></div></pre></td></tr></table></figure>\n</li>\n<li><p>表单使用二进制编码方式</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">form</span> <span class=\"attr\">...</span> <span class=\"attr\">enctype</span>=<span class=\"string\">\"multipart/form-data\"</span> <span class=\"attr\">...</span>/></span></div></pre></td></tr></table></figure>\n</li>\n<li><p>备注:在servlet中获取上传文件的注意</p>\n<blockquote>\n<p>当表单使用二进制编码之后,此时再也不能直接使用<code>request.getParameter</code>方法来获取请求参数了.因为<code>request.getParameter</code>就仅仅只能获取<code>application/x-www-form-urlencoded</code>编码方式的参数.</p>\n</blockquote>\n</li>\n</ul>\n<h3 id=\"环境准备\"><a href=\"#环境准备\" class=\"headerlink\" title=\"环境准备\"></a>环境准备</h3><ul>\n<li><p>文件上传依赖的jar包</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">commons-fileupload-1.2.2.jar</div><div class=\"line\">commons-io-1.4.jar</div></pre></td></tr></table></figure>\n</li>\n<li><p>下载地址<br>commons-fileupload:<a href=\"http://commons.apache.org/fileupload/\" target=\"_blank\" rel=\"external\">http://commons.apache.org/fileupload/</a><br>commons-io:<a href=\"http://commons.apache.org/io/\" target=\"_blank\" rel=\"external\">http://commons.apache.org/io/</a></p>\n</li>\n</ul>\n<h3 id=\"代码实现\"><a href=\"#代码实现\" class=\"headerlink\" title=\"代码实现\"></a>代码实现</h3><ol>\n<li><p>检查文件上传的请求:请求方式是否是POST,context-type是否是multipart/form-data</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">boolean</span> isMultipart = ServletFileUpload.isMultipartContent(request);</div></pre></td></tr></table></figure>\n</li>\n<li><p>创建一个FileItemd的工厂对象,目的是创建FileItem对象</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">FileItemFactory factory = <span class=\"keyword\">new</span> DiskFileItemFactory();</div></pre></td></tr></table></figure>\n</li>\n<li><p>创建文件上传处理器</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">ServletFileUpload upload = <span class=\"keyword\">new</span> ServletFileUpload(factory);</div></pre></td></tr></table></figure>\n</li>\n<li><p>文件上传处理器解析请求,解析请求需要抛出FileUploadException</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">List<FileItem> items = upload.parseRequest(req);</div></pre></td></tr></table></figure>\n</li>\n<li><p>处理器解析出来请求包含:普通表单item和文件表单item</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div></pre></td><td class=\"code\"><pre><div class=\"line\">Iterator<FileItem> it = items.iterator();</div><div class=\"line\"><span class=\"keyword\">while</span>(it.hasNext()){</div><div class=\"line\">\tFileItem fileItem = it.next();</div><div class=\"line\">\t<span class=\"keyword\">if</span>(fileItem.isFormField()){</div><div class=\"line\">\t\t<span class=\"comment\">//普通表单item,获取用户在控件中个输入的value</span></div><div class=\"line\">\t\tSystem.out.println(fileItem.getString(<span class=\"string\">\"UTF-8\"</span>));</div><div class=\"line\">\t}<span class=\"keyword\">else</span>{</div><div class=\"line\">\t\t<span class=\"comment\">//文件表单item,保存到服务器磁盘upload文件夹中</span></div><div class=\"line\">\t\tString dir = <span class=\"keyword\">super</span>.getServletContext().getRealPath(<span class=\"string\">\"/upload\"</span>);</div><div class=\"line\">\t\tString randomFileName = UUID.randomUUID().toString()+<span class=\"string\">\".\"</span>+FilenameUtils.getExtension(fileItem.getName());</div><div class=\"line\"> <span class=\"comment\">//保存到磁盘需要抛出异常,此处仅标明</span></div><div class=\"line\">\t\tfileItem.write(<span class=\"keyword\">new</span> File(dir, randomFileName));</div><div class=\"line\">\t}</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n<li><p>jsp页面</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">form</span> <span class=\"attr\">action</span>=<span class=\"string\">\"/upload\"</span> <span class=\"attr\">method</span>=<span class=\"string\">\"post\"</span> <span class=\"attr\">enctype</span>=<span class=\"string\">\"multipart/form-data\"</span>></span></div><div class=\"line\">\t账户:</div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"text\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"username\"</span>/></span><span class=\"tag\"><<span class=\"name\">br</span>></span></div><div class=\"line\">\t邮箱:</div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"text\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"email\"</span>/></span><span class=\"tag\"><<span class=\"name\">br</span>></span></div><div class=\"line\">\t头像:</div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"file\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"headImg\"</span>/></span><span class=\"tag\"><<span class=\"name\">br</span>></span></div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"submit\"</span> <span class=\"attr\">value</span>=<span class=\"string\">\"保存\"</span>/></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">form</span>></span></div></pre></td></tr></table></figure>\n</li>\n</ol>\n<pre><code class=\"bash\">\n</code></pre>\n","excerpt":"","more":"<h3 id=\"必须的准备工作\"><a href=\"#必须的准备工作\" class=\"headerlink\" title=\"必须的准备工作\"></a>必须的准备工作</h3><ul>\n<li>文件上传的表单提交方式须用POST,因为GET方式适用于url,若传输数据大小不能超过2KB</li>\n<li><p>须有文件上传控件:</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">”file”</span> <span class=\"attr\">name</span>=<span class=\"string\">”filename”/</span>></span></div></pre></td></tr></table></figure>\n</li>\n<li><p>表单使用二进制编码方式</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">form</span> <span class=\"attr\">...</span> <span class=\"attr\">enctype</span>=<span class=\"string\">\"multipart/form-data\"</span> <span class=\"attr\">...</span>/></span></div></pre></td></tr></table></figure>\n</li>\n<li><p>备注:在servlet中获取上传文件的注意</p>\n<blockquote>\n<p>当表单使用二进制编码之后,此时再也不能直接使用<code>request.getParameter</code>方法来获取请求参数了.因为<code>request.getParameter</code>就仅仅只能获取<code>application/x-www-form-urlencoded</code>编码方式的参数.</p>\n</blockquote>\n</li>\n</ul>\n<h3 id=\"环境准备\"><a href=\"#环境准备\" class=\"headerlink\" title=\"环境准备\"></a>环境准备</h3><ul>\n<li><p>文件上传依赖的jar包</p>\n<figure class=\"highlight bash\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">commons-fileupload-1.2.2.jar</div><div class=\"line\">commons-io-1.4.jar</div></pre></td></tr></table></figure>\n</li>\n<li><p>下载地址<br>commons-fileupload:<a href=\"http://commons.apache.org/fileupload/\">http://commons.apache.org/fileupload/</a><br>commons-io:<a href=\"http://commons.apache.org/io/\">http://commons.apache.org/io/</a></p>\n</li>\n</ul>\n<h3 id=\"代码实现\"><a href=\"#代码实现\" class=\"headerlink\" title=\"代码实现\"></a>代码实现</h3><ol>\n<li><p>检查文件上传的请求:请求方式是否是POST,context-type是否是multipart/form-data</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">boolean</span> isMultipart = ServletFileUpload.isMultipartContent(request);</div></pre></td></tr></table></figure>\n</li>\n<li><p>创建一个FileItemd的工厂对象,目的是创建FileItem对象</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">FileItemFactory factory = <span class=\"keyword\">new</span> DiskFileItemFactory();</div></pre></td></tr></table></figure>\n</li>\n<li><p>创建文件上传处理器</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">ServletFileUpload upload = <span class=\"keyword\">new</span> ServletFileUpload(factory);</div></pre></td></tr></table></figure>\n</li>\n<li><p>文件上传处理器解析请求,解析请求需要抛出FileUploadException</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">List<FileItem> items = upload.parseRequest(req);</div></pre></td></tr></table></figure>\n</li>\n<li><p>处理器解析出来请求包含:普通表单item和文件表单item</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div></pre></td><td class=\"code\"><pre><div class=\"line\">Iterator<FileItem> it = items.iterator();</div><div class=\"line\"><span class=\"keyword\">while</span>(it.hasNext()){</div><div class=\"line\">\tFileItem fileItem = it.next();</div><div class=\"line\">\t<span class=\"keyword\">if</span>(fileItem.isFormField()){</div><div class=\"line\">\t\t<span class=\"comment\">//普通表单item,获取用户在控件中个输入的value</span></div><div class=\"line\">\t\tSystem.out.println(fileItem.getString(<span class=\"string\">\"UTF-8\"</span>));</div><div class=\"line\">\t}<span class=\"keyword\">else</span>{</div><div class=\"line\">\t\t<span class=\"comment\">//文件表单item,保存到服务器磁盘upload文件夹中</span></div><div class=\"line\">\t\tString dir = <span class=\"keyword\">super</span>.getServletContext().getRealPath(<span class=\"string\">\"/upload\"</span>);</div><div class=\"line\">\t\tString randomFileName = UUID.randomUUID().toString()+<span class=\"string\">\".\"</span>+FilenameUtils.getExtension(fileItem.getName());</div><div class=\"line\"> <span class=\"comment\">//保存到磁盘需要抛出异常,此处仅标明</span></div><div class=\"line\">\t\tfileItem.write(<span class=\"keyword\">new</span> File(dir, randomFileName));</div><div class=\"line\">\t}</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n</li>\n<li><p>jsp页面</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">form</span> <span class=\"attr\">action</span>=<span class=\"string\">\"/upload\"</span> <span class=\"attr\">method</span>=<span class=\"string\">\"post\"</span> <span class=\"attr\">enctype</span>=<span class=\"string\">\"multipart/form-data\"</span>></span></div><div class=\"line\">\t账户:</div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"text\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"username\"</span>/></span><span class=\"tag\"><<span class=\"name\">br</span>></span></div><div class=\"line\">\t邮箱:</div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"text\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"email\"</span>/></span><span class=\"tag\"><<span class=\"name\">br</span>></span></div><div class=\"line\">\t头像:</div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"file\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"headImg\"</span>/></span><span class=\"tag\"><<span class=\"name\">br</span>></span></div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"submit\"</span> <span class=\"attr\">value</span>=<span class=\"string\">\"保存\"</span>/></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">form</span>></span></div></pre></td></tr></table></figure>\n</li>\n</ol>\n<pre><code class=\"bash\">\n</code></pre>\n"},{"title":"Spring Boot运行原理","date":"2018-01-10T03:21:24.000Z","_content":"\n @SpringBootApplication 是Spring Boot的核心注解,它是一个组合注解,源码如下:\n``` java\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\n@Inherited\n@SpringBootConfiguration\n@EnableAutoConfiguration\n@ComponentScan(excludeFilters = {\n\t\t@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),\n\t\t@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })\npublic @interface SpringBootApplication {\n\tClass<?>[] exclude() default {};\n\tString[] excludeName() default {};\n\tString[] scanBasePackages() default {};\n\tClass<?>[] scanBasePackageClasses() default {};\n}\n```\n\n","source":"_posts/Spring Boot运行原理.md","raw":"---\ntitle: Spring Boot运行原理\ndate: 2018-01-10 11:21:24\ncategories: 编程 \ntags: [Java] \n---\n\n @SpringBootApplication 是Spring Boot的核心注解,它是一个组合注解,源码如下:\n``` java\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\n@Inherited\n@SpringBootConfiguration\n@EnableAutoConfiguration\n@ComponentScan(excludeFilters = {\n\t\t@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),\n\t\t@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })\npublic @interface SpringBootApplication {\n\tClass<?>[] exclude() default {};\n\tString[] excludeName() default {};\n\tString[] scanBasePackages() default {};\n\tClass<?>[] scanBasePackageClasses() default {};\n}\n```\n\n","slug":"Spring Boot运行原理","published":1,"updated":"2018-01-10T03:51:26.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaieo00143sascdjhf5rk","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><pre><code>@SpringBootApplication 是Spring Boot的核心注解,它是一个组合注解,源码如下:\n</code></pre><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"meta\">@Target</span>(ElementType.TYPE)</div><div class=\"line\"><span class=\"meta\">@Retention</span>(RetentionPolicy.RUNTIME)</div><div class=\"line\"><span class=\"meta\">@Documented</span></div><div class=\"line\"><span class=\"meta\">@Inherited</span></div><div class=\"line\"><span class=\"meta\">@SpringBootConfiguration</span></div><div class=\"line\"><span class=\"meta\">@EnableAutoConfiguration</span></div><div class=\"line\"><span class=\"meta\">@ComponentScan</span>(excludeFilters = {</div><div class=\"line\">\t\t<span class=\"meta\">@Filter</span>(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),</div><div class=\"line\">\t\t<span class=\"meta\">@Filter</span>(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })</div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"meta\">@interface</span> SpringBootApplication {</div><div class=\"line\">\tClass<?>[] exclude() <span class=\"keyword\">default</span> {};</div><div class=\"line\">\tString[] excludeName() <span class=\"keyword\">default</span> {};</div><div class=\"line\">\tString[] scanBasePackages() <span class=\"keyword\">default</span> {};</div><div class=\"line\">\tClass<?>[] scanBasePackageClasses() <span class=\"keyword\">default</span> {};</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n","excerpt":"","more":"<pre><code>@SpringBootApplication 是Spring Boot的核心注解,它是一个组合注解,源码如下:\n</code></pre><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"meta\">@Target</span>(ElementType.TYPE)</div><div class=\"line\"><span class=\"meta\">@Retention</span>(RetentionPolicy.RUNTIME)</div><div class=\"line\"><span class=\"meta\">@Documented</span></div><div class=\"line\"><span class=\"meta\">@Inherited</span></div><div class=\"line\"><span class=\"meta\">@SpringBootConfiguration</span></div><div class=\"line\"><span class=\"meta\">@EnableAutoConfiguration</span></div><div class=\"line\"><span class=\"meta\">@ComponentScan</span>(excludeFilters = {</div><div class=\"line\">\t\t<span class=\"meta\">@Filter</span>(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),</div><div class=\"line\">\t\t<span class=\"meta\">@Filter</span>(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })</div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"meta\">@interface</span> SpringBootApplication {</div><div class=\"line\">\tClass<?>[] exclude() <span class=\"keyword\">default</span> {};</div><div class=\"line\">\tString[] excludeName() <span class=\"keyword\">default</span> {};</div><div class=\"line\">\tString[] scanBasePackages() <span class=\"keyword\">default</span> {};</div><div class=\"line\">\tClass<?>[] scanBasePackageClasses() <span class=\"keyword\">default</span> {};</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n"},{"title":"简单实例之文件上传(二),基于Struts2项目中","date":"2016-08-10T16:32:11.000Z","_content":"\n### 在`upload.jsp`页面中,使用的是struts的ognl表达式 \n定义action,template是在`struts.xml`文件中的action标签的name属性,upload是执行方法,namespace是package标签的namespace属性,文件上传表单方法必须是post,enctype必须是`mutipart/form-data`。input标签是文件上传控件,name属性取名resource(在Action类中的field名字须一致) \n``` html \n<s:form action=\"template_upload\" namespace=\"/\" method=\"post\" enctype=\"multipart/form-data\">\n\t<input type=\"file\" name=\"resource\"/>\n</s:form> \n```\n\n### 在TemplateAction中,web项目的控制层分别设置filed、执行方法和抽取的文件上传方法 \n* 实现下列field的setter方法 \n\n``` java\nprivate File resource;//必须有,名称resource根据jsp中input标签的name属性一致\nprivate String resourceFileName;//可不用\nprivate String resourceContentType;//可不用 \n```\n\n* 定义文件上传的执行方法,`getFilePath(resource)`是抽取出来的方法,这里是调用。upload返回给`struts.xml`文件。\n\n``` java\npublic String upload(){\n this.getFilePath(resource);\n return \"upload\";\n}\n```\n\n* 文件上传的具体实现,此处没有使用copy的方式存储上传的文件,而是调用`renameTo()`的方法,可以理解为“文件从一个文件夹剪切到另一个文件夹,同时这个过程可以重新命名该文件”\n\n``` java\nprivate String getFilePath(File srcFile) {\n String filePath = null;\n if(resource != null){\n\t\t//获取目标文件夹的绝对路径\n String realPath = ServletActionContext.getServletContext().getRealPath(\"/upload\");\n File dateFile = new File(realPath);\n if(!dateFile.exists()){\n\t\t\t//若目录不存在,调用mkdirs()创建多级目录\n realPath.mkdirs();\n }\n filePath = realPath+UUID.randomUUID().toString()+\".\"+FilenameUtils.getExtension(srcFile.getName());\n //renameTo移动文件,即上传文件\n File dest = new File(filePath);\n srcFile.renameTo(dest);\n }\n return filePath;\n}\n```\n\n### 在struts.xml中\n这里配置的是文件上传完毕后,网页从`upload.jsp`页面跳转到`xxx.jsp`页面。class属性是TemplateAction的全限定名,method是TemplateAction中的执行方法。\n\n``` xml\n<action name=\"template_*\" class=\"com.yanlin.oa.action.TemplateAction\" method=\"upload\">\n\t<result type=\"upload\">/WEB-INF/jsp/xxx.jsp</result>\n</action>\n```\n","source":"_posts/文件上传.md","raw":"---\ntitle: 简单实例之文件上传(二),基于Struts2项目中 \ndate: 2016-08-11 00:32:11 \ncategories: 编程 \ntags: [Java] \n---\n\n### 在`upload.jsp`页面中,使用的是struts的ognl表达式 \n定义action,template是在`struts.xml`文件中的action标签的name属性,upload是执行方法,namespace是package标签的namespace属性,文件上传表单方法必须是post,enctype必须是`mutipart/form-data`。input标签是文件上传控件,name属性取名resource(在Action类中的field名字须一致) \n``` html \n<s:form action=\"template_upload\" namespace=\"/\" method=\"post\" enctype=\"multipart/form-data\">\n\t<input type=\"file\" name=\"resource\"/>\n</s:form> \n```\n\n### 在TemplateAction中,web项目的控制层分别设置filed、执行方法和抽取的文件上传方法 \n* 实现下列field的setter方法 \n\n``` java\nprivate File resource;//必须有,名称resource根据jsp中input标签的name属性一致\nprivate String resourceFileName;//可不用\nprivate String resourceContentType;//可不用 \n```\n\n* 定义文件上传的执行方法,`getFilePath(resource)`是抽取出来的方法,这里是调用。upload返回给`struts.xml`文件。\n\n``` java\npublic String upload(){\n this.getFilePath(resource);\n return \"upload\";\n}\n```\n\n* 文件上传的具体实现,此处没有使用copy的方式存储上传的文件,而是调用`renameTo()`的方法,可以理解为“文件从一个文件夹剪切到另一个文件夹,同时这个过程可以重新命名该文件”\n\n``` java\nprivate String getFilePath(File srcFile) {\n String filePath = null;\n if(resource != null){\n\t\t//获取目标文件夹的绝对路径\n String realPath = ServletActionContext.getServletContext().getRealPath(\"/upload\");\n File dateFile = new File(realPath);\n if(!dateFile.exists()){\n\t\t\t//若目录不存在,调用mkdirs()创建多级目录\n realPath.mkdirs();\n }\n filePath = realPath+UUID.randomUUID().toString()+\".\"+FilenameUtils.getExtension(srcFile.getName());\n //renameTo移动文件,即上传文件\n File dest = new File(filePath);\n srcFile.renameTo(dest);\n }\n return filePath;\n}\n```\n\n### 在struts.xml中\n这里配置的是文件上传完毕后,网页从`upload.jsp`页面跳转到`xxx.jsp`页面。class属性是TemplateAction的全限定名,method是TemplateAction中的执行方法。\n\n``` xml\n<action name=\"template_*\" class=\"com.yanlin.oa.action.TemplateAction\" method=\"upload\">\n\t<result type=\"upload\">/WEB-INF/jsp/xxx.jsp</result>\n</action>\n```\n","slug":"文件上传","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaieq00173sasfmtcsz8r","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"在upload-jsp页面中,使用的是struts的ognl表达式\"><a href=\"#在upload-jsp页面中,使用的是struts的ognl表达式\" class=\"headerlink\" title=\"在upload.jsp页面中,使用的是struts的ognl表达式\"></a>在<code>upload.jsp</code>页面中,使用的是struts的ognl表达式</h3><p>定义action,template是在<code>struts.xml</code>文件中的action标签的name属性,upload是执行方法,namespace是package标签的namespace属性,文件上传表单方法必须是post,enctype必须是<code>mutipart/form-data</code>。input标签是文件上传控件,name属性取名resource(在Action类中的field名字须一致)<br><figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">s:form</span> <span class=\"attr\">action</span>=<span class=\"string\">\"template_upload\"</span> <span class=\"attr\">namespace</span>=<span class=\"string\">\"/\"</span> <span class=\"attr\">method</span>=<span class=\"string\">\"post\"</span> <span class=\"attr\">enctype</span>=<span class=\"string\">\"multipart/form-data\"</span>></span></div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"file\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"resource\"</span>/></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">s:form</span>></span></div></pre></td></tr></table></figure></p>\n<h3 id=\"在TemplateAction中-web项目的控制层分别设置filed、执行方法和抽取的文件上传方法\"><a href=\"#在TemplateAction中-web项目的控制层分别设置filed、执行方法和抽取的文件上传方法\" class=\"headerlink\" title=\"在TemplateAction中,web项目的控制层分别设置filed、执行方法和抽取的文件上传方法\"></a>在TemplateAction中,web项目的控制层分别设置filed、执行方法和抽取的文件上传方法</h3><ul>\n<li>实现下列field的setter方法 </li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">private</span> File resource;<span class=\"comment\">//必须有,名称resource根据jsp中input标签的name属性一致</span></div><div class=\"line\"><span class=\"keyword\">private</span> String resourceFileName;<span class=\"comment\">//可不用</span></div><div class=\"line\"><span class=\"keyword\">private</span> String resourceContentType;<span class=\"comment\">//可不用</span></div></pre></td></tr></table></figure>\n<ul>\n<li>定义文件上传的执行方法,<code>getFilePath(resource)</code>是抽取出来的方法,这里是调用。upload返回给<code>struts.xml</code>文件。</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">upload</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> <span class=\"keyword\">this</span>.getFilePath(resource);</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"string\">\"upload\"</span>;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<ul>\n<li>文件上传的具体实现,此处没有使用copy的方式存储上传的文件,而是调用<code>renameTo()</code>的方法,可以理解为“文件从一个文件夹剪切到另一个文件夹,同时这个过程可以重新命名该文件”</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">private</span> String <span class=\"title\">getFilePath</span><span class=\"params\">(File srcFile)</span> </span>{</div><div class=\"line\"> String filePath = <span class=\"keyword\">null</span>;</div><div class=\"line\"> <span class=\"keyword\">if</span>(resource != <span class=\"keyword\">null</span>){</div><div class=\"line\">\t\t<span class=\"comment\">//获取目标文件夹的绝对路径</span></div><div class=\"line\"> String realPath = ServletActionContext.getServletContext().getRealPath(<span class=\"string\">\"/upload\"</span>);</div><div class=\"line\"> File dateFile = <span class=\"keyword\">new</span> File(realPath);</div><div class=\"line\"> <span class=\"keyword\">if</span>(!dateFile.exists()){</div><div class=\"line\">\t\t\t<span class=\"comment\">//若目录不存在,调用mkdirs()创建多级目录</span></div><div class=\"line\"> realPath.mkdirs();</div><div class=\"line\"> }</div><div class=\"line\"> filePath = realPath+UUID.randomUUID().toString()+<span class=\"string\">\".\"</span>+FilenameUtils.getExtension(srcFile.getName());</div><div class=\"line\"> <span class=\"comment\">//renameTo移动文件,即上传文件</span></div><div class=\"line\"> File dest = <span class=\"keyword\">new</span> File(filePath);</div><div class=\"line\"> srcFile.renameTo(dest);</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> filePath;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"在struts-xml中\"><a href=\"#在struts-xml中\" class=\"headerlink\" title=\"在struts.xml中\"></a>在struts.xml中</h3><p>这里配置的是文件上传完毕后,网页从<code>upload.jsp</code>页面跳转到<code>xxx.jsp</code>页面。class属性是TemplateAction的全限定名,method是TemplateAction中的执行方法。</p>\n<figure class=\"highlight xml\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">action</span> <span class=\"attr\">name</span>=<span class=\"string\">\"template_*\"</span> <span class=\"attr\">class</span>=<span class=\"string\">\"com.yanlin.oa.action.TemplateAction\"</span> <span class=\"attr\">method</span>=<span class=\"string\">\"upload\"</span>></span></div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">result</span> <span class=\"attr\">type</span>=<span class=\"string\">\"upload\"</span>></span>/WEB-INF/jsp/xxx.jsp<span class=\"tag\"></<span class=\"name\">result</span>></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">action</span>></span></div></pre></td></tr></table></figure>\n","excerpt":"","more":"<h3 id=\"在upload-jsp页面中,使用的是struts的ognl表达式\"><a href=\"#在upload-jsp页面中,使用的是struts的ognl表达式\" class=\"headerlink\" title=\"在upload.jsp页面中,使用的是struts的ognl表达式\"></a>在<code>upload.jsp</code>页面中,使用的是struts的ognl表达式</h3><p>定义action,template是在<code>struts.xml</code>文件中的action标签的name属性,upload是执行方法,namespace是package标签的namespace属性,文件上传表单方法必须是post,enctype必须是<code>mutipart/form-data</code>。input标签是文件上传控件,name属性取名resource(在Action类中的field名字须一致)<br><figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">s:form</span> <span class=\"attr\">action</span>=<span class=\"string\">\"template_upload\"</span> <span class=\"attr\">namespace</span>=<span class=\"string\">\"/\"</span> <span class=\"attr\">method</span>=<span class=\"string\">\"post\"</span> <span class=\"attr\">enctype</span>=<span class=\"string\">\"multipart/form-data\"</span>></span></div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">input</span> <span class=\"attr\">type</span>=<span class=\"string\">\"file\"</span> <span class=\"attr\">name</span>=<span class=\"string\">\"resource\"</span>/></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">s:form</span>></span></div></pre></td></tr></table></figure></p>\n<h3 id=\"在TemplateAction中-web项目的控制层分别设置filed、执行方法和抽取的文件上传方法\"><a href=\"#在TemplateAction中-web项目的控制层分别设置filed、执行方法和抽取的文件上传方法\" class=\"headerlink\" title=\"在TemplateAction中,web项目的控制层分别设置filed、执行方法和抽取的文件上传方法\"></a>在TemplateAction中,web项目的控制层分别设置filed、执行方法和抽取的文件上传方法</h3><ul>\n<li>实现下列field的setter方法 </li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">private</span> File resource;<span class=\"comment\">//必须有,名称resource根据jsp中input标签的name属性一致</span></div><div class=\"line\"><span class=\"keyword\">private</span> String resourceFileName;<span class=\"comment\">//可不用</span></div><div class=\"line\"><span class=\"keyword\">private</span> String resourceContentType;<span class=\"comment\">//可不用</span></div></pre></td></tr></table></figure>\n<ul>\n<li>定义文件上传的执行方法,<code>getFilePath(resource)</code>是抽取出来的方法,这里是调用。upload返回给<code>struts.xml</code>文件。</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">upload</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> <span class=\"keyword\">this</span>.getFilePath(resource);</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"string\">\"upload\"</span>;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<ul>\n<li>文件上传的具体实现,此处没有使用copy的方式存储上传的文件,而是调用<code>renameTo()</code>的方法,可以理解为“文件从一个文件夹剪切到另一个文件夹,同时这个过程可以重新命名该文件”</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">private</span> String <span class=\"title\">getFilePath</span><span class=\"params\">(File srcFile)</span> </span>{</div><div class=\"line\"> String filePath = <span class=\"keyword\">null</span>;</div><div class=\"line\"> <span class=\"keyword\">if</span>(resource != <span class=\"keyword\">null</span>){</div><div class=\"line\">\t\t<span class=\"comment\">//获取目标文件夹的绝对路径</span></div><div class=\"line\"> String realPath = ServletActionContext.getServletContext().getRealPath(<span class=\"string\">\"/upload\"</span>);</div><div class=\"line\"> File dateFile = <span class=\"keyword\">new</span> File(realPath);</div><div class=\"line\"> <span class=\"keyword\">if</span>(!dateFile.exists()){</div><div class=\"line\">\t\t\t<span class=\"comment\">//若目录不存在,调用mkdirs()创建多级目录</span></div><div class=\"line\"> realPath.mkdirs();</div><div class=\"line\"> }</div><div class=\"line\"> filePath = realPath+UUID.randomUUID().toString()+<span class=\"string\">\".\"</span>+FilenameUtils.getExtension(srcFile.getName());</div><div class=\"line\"> <span class=\"comment\">//renameTo移动文件,即上传文件</span></div><div class=\"line\"> File dest = <span class=\"keyword\">new</span> File(filePath);</div><div class=\"line\"> srcFile.renameTo(dest);</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> filePath;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"在struts-xml中\"><a href=\"#在struts-xml中\" class=\"headerlink\" title=\"在struts.xml中\"></a>在struts.xml中</h3><p>这里配置的是文件上传完毕后,网页从<code>upload.jsp</code>页面跳转到<code>xxx.jsp</code>页面。class属性是TemplateAction的全限定名,method是TemplateAction中的执行方法。</p>\n<figure class=\"highlight xml\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">action</span> <span class=\"attr\">name</span>=<span class=\"string\">\"template_*\"</span> <span class=\"attr\">class</span>=<span class=\"string\">\"com.yanlin.oa.action.TemplateAction\"</span> <span class=\"attr\">method</span>=<span class=\"string\">\"upload\"</span>></span></div><div class=\"line\">\t<span class=\"tag\"><<span class=\"name\">result</span> <span class=\"attr\">type</span>=<span class=\"string\">\"upload\"</span>></span>/WEB-INF/jsp/xxx.jsp<span class=\"tag\"></<span class=\"name\">result</span>></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">action</span>></span></div></pre></td></tr></table></figure>\n"},{"title":"简单实例之文件下载(一)","date":"2016-08-11T14:59:26.000Z","_content":"\n1. 在web项目中,若是将待下载文件放在`WEB-INF`目录外面,客户端是可以通过超链接访问直接就能下载。\n\n``` html\n<a href=\"/download/Java第一部.zip\">Java机密第一部</a>\n<a href=\"/download/Java第二部.zip\">Java机密第二部</a>\n```\n\n2. 但要是把待下载文件放在`WEB-INF`目录下`/WEB-INF/download/Java.zip`,就要通过servlet来下载。href属性中的`/download`表示和使用注解配置的servlet`@WebServlet(\"/download\")`一致。fileName用来获取要下载哪一个文件\n\n``` html\n<a href=\"/download?fileName=Java第一部.zip\">Java机密第一部</a>\n<a href=\"/download?fileName=Java第二部.zip\">Java机密第二部</a>\n```\n\n3. 在servlet中,使用的是`service()`方法\n\n获取待下载文件的名称,确定是要下载哪一个文件\n\n``` java\nString fileName = request.getParameter(\"fileName\");\n```\n\n根据下载文件名称从当前应用中获取该资源\n\n``` java\nString dir = super.getServletContext().getRealPath(\"/WEB=INF/download\");\nFile file = new File(dir,fileName);\n```\n\n - 注意一:tell浏览器该文件应该被保存,不应该被打开(部分浏览器支持该功能)\n\n``` java\nresponse.setContentType(\"application/x-msdownload\");\n```\n\n\n - 注意二:设置下载文件的保存名称\n\n``` java\nString userAgent = request.getHeader(\"User-Agent\");\nif(userAgent.contains(\"MSIE\")){\n //客户端使用IE浏览器\n fileName = URLEncoder.encoder(fileName,\"UTF-8\");\n}else{}\n //w3c浏览器(非IE)\n fileName = new String(fileName.getBytes(\"UTF-8\"),\"ISO-8859-1\");\n}\nresponse.setHeader(\"Content-Disposition\",\"attachment;fileName=\"+fileName);\n```\n\n把该文件-->写入到程序-->写出到浏览器:从服务端磁盘中拷贝到客户端的磁盘保存\n\n``` java\nFiles.copy(Paths.get(file.getAbsolutePath()),response.getOutputStream());\n```\n","source":"_posts/简单实例之文件下载.md","raw":"---\ntitle: 简单实例之文件下载(一)\ndate: 2016-08-11 22:59:26\ncategories: 编程 \ntags: [Java] \n---\n\n1. 在web项目中,若是将待下载文件放在`WEB-INF`目录外面,客户端是可以通过超链接访问直接就能下载。\n\n``` html\n<a href=\"/download/Java第一部.zip\">Java机密第一部</a>\n<a href=\"/download/Java第二部.zip\">Java机密第二部</a>\n```\n\n2. 但要是把待下载文件放在`WEB-INF`目录下`/WEB-INF/download/Java.zip`,就要通过servlet来下载。href属性中的`/download`表示和使用注解配置的servlet`@WebServlet(\"/download\")`一致。fileName用来获取要下载哪一个文件\n\n``` html\n<a href=\"/download?fileName=Java第一部.zip\">Java机密第一部</a>\n<a href=\"/download?fileName=Java第二部.zip\">Java机密第二部</a>\n```\n\n3. 在servlet中,使用的是`service()`方法\n\n获取待下载文件的名称,确定是要下载哪一个文件\n\n``` java\nString fileName = request.getParameter(\"fileName\");\n```\n\n根据下载文件名称从当前应用中获取该资源\n\n``` java\nString dir = super.getServletContext().getRealPath(\"/WEB=INF/download\");\nFile file = new File(dir,fileName);\n```\n\n - 注意一:tell浏览器该文件应该被保存,不应该被打开(部分浏览器支持该功能)\n\n``` java\nresponse.setContentType(\"application/x-msdownload\");\n```\n\n\n - 注意二:设置下载文件的保存名称\n\n``` java\nString userAgent = request.getHeader(\"User-Agent\");\nif(userAgent.contains(\"MSIE\")){\n //客户端使用IE浏览器\n fileName = URLEncoder.encoder(fileName,\"UTF-8\");\n}else{}\n //w3c浏览器(非IE)\n fileName = new String(fileName.getBytes(\"UTF-8\"),\"ISO-8859-1\");\n}\nresponse.setHeader(\"Content-Disposition\",\"attachment;fileName=\"+fileName);\n```\n\n把该文件-->写入到程序-->写出到浏览器:从服务端磁盘中拷贝到客户端的磁盘保存\n\n``` java\nFiles.copy(Paths.get(file.getAbsolutePath()),response.getOutputStream());\n```\n","slug":"简单实例之文件下载","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaiet001c3sasqag98bj5","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><ol>\n<li>在web项目中,若是将待下载文件放在<code>WEB-INF</code>目录外面,客户端是可以通过超链接访问直接就能下载。</li>\n</ol>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download/Java第一部.zip\"</span>></span>Java机密第一部<span class=\"tag\"></<span class=\"name\">a</span>></span></div><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download/Java第二部.zip\"</span>></span>Java机密第二部<span class=\"tag\"></<span class=\"name\">a</span>></span></div></pre></td></tr></table></figure>\n<ol>\n<li>但要是把待下载文件放在<code>WEB-INF</code>目录下<code>/WEB-INF/download/Java.zip</code>,就要通过servlet来下载。href属性中的<code>/download</code>表示和使用注解配置的servlet<code>@WebServlet("/download")</code>一致。fileName用来获取要下载哪一个文件</li>\n</ol>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download?fileName=Java第一部.zip\"</span>></span>Java机密第一部<span class=\"tag\"></<span class=\"name\">a</span>></span></div><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download?fileName=Java第二部.zip\"</span>></span>Java机密第二部<span class=\"tag\"></<span class=\"name\">a</span>></span></div></pre></td></tr></table></figure>\n<ol>\n<li>在servlet中,使用的是<code>service()</code>方法</li>\n</ol>\n<p>获取待下载文件的名称,确定是要下载哪一个文件</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">String fileName = request.getParameter(<span class=\"string\">\"fileName\"</span>);</div></pre></td></tr></table></figure>\n<p>根据下载文件名称从当前应用中获取该资源</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">String dir = <span class=\"keyword\">super</span>.getServletContext().getRealPath(<span class=\"string\">\"/WEB=INF/download\"</span>);</div><div class=\"line\">File file = <span class=\"keyword\">new</span> File(dir,fileName);</div></pre></td></tr></table></figure>\n<ul>\n<li>注意一:tell浏览器该文件应该被保存,不应该被打开(部分浏览器支持该功能)</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">response.setContentType(<span class=\"string\">\"application/x-msdownload\"</span>);</div></pre></td></tr></table></figure>\n<ul>\n<li>注意二:设置下载文件的保存名称</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\">String userAgent = request.getHeader(<span class=\"string\">\"User-Agent\"</span>);</div><div class=\"line\"><span class=\"keyword\">if</span>(userAgent.contains(<span class=\"string\">\"MSIE\"</span>)){</div><div class=\"line\"> <span class=\"comment\">//客户端使用IE浏览器</span></div><div class=\"line\"> fileName = URLEncoder.encoder(fileName,<span class=\"string\">\"UTF-8\"</span>);</div><div class=\"line\">}<span class=\"keyword\">else</span>{}</div><div class=\"line\"> <span class=\"comment\">//w3c浏览器(非IE)</span></div><div class=\"line\"> fileName = <span class=\"keyword\">new</span> String(fileName.getBytes(<span class=\"string\">\"UTF-8\"</span>),<span class=\"string\">\"ISO-8859-1\"</span>);</div><div class=\"line\">}</div><div class=\"line\">response.setHeader(<span class=\"string\">\"Content-Disposition\"</span>,<span class=\"string\">\"attachment;fileName=\"</span>+fileName);</div></pre></td></tr></table></figure>\n<p>把该文件–>写入到程序–>写出到浏览器:从服务端磁盘中拷贝到客户端的磁盘保存</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">Files.copy(Paths.get(file.getAbsolutePath()),response.getOutputStream());</div></pre></td></tr></table></figure>\n","excerpt":"","more":"<ol>\n<li>在web项目中,若是将待下载文件放在<code>WEB-INF</code>目录外面,客户端是可以通过超链接访问直接就能下载。</li>\n</ol>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download/Java第一部.zip\"</span>></span>Java机密第一部<span class=\"tag\"></<span class=\"name\">a</span>></span></div><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download/Java第二部.zip\"</span>></span>Java机密第二部<span class=\"tag\"></<span class=\"name\">a</span>></span></div></pre></td></tr></table></figure>\n<ol>\n<li>但要是把待下载文件放在<code>WEB-INF</code>目录下<code>/WEB-INF/download/Java.zip</code>,就要通过servlet来下载。href属性中的<code>/download</code>表示和使用注解配置的servlet<code>@WebServlet("/download")</code>一致。fileName用来获取要下载哪一个文件</li>\n</ol>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download?fileName=Java第一部.zip\"</span>></span>Java机密第一部<span class=\"tag\"></<span class=\"name\">a</span>></span></div><div class=\"line\"><span class=\"tag\"><<span class=\"name\">a</span> <span class=\"attr\">href</span>=<span class=\"string\">\"/download?fileName=Java第二部.zip\"</span>></span>Java机密第二部<span class=\"tag\"></<span class=\"name\">a</span>></span></div></pre></td></tr></table></figure>\n<ol>\n<li>在servlet中,使用的是<code>service()</code>方法</li>\n</ol>\n<p>获取待下载文件的名称,确定是要下载哪一个文件</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">String fileName = request.getParameter(<span class=\"string\">\"fileName\"</span>);</div></pre></td></tr></table></figure>\n<p>根据下载文件名称从当前应用中获取该资源</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">String dir = <span class=\"keyword\">super</span>.getServletContext().getRealPath(<span class=\"string\">\"/WEB=INF/download\"</span>);</div><div class=\"line\">File file = <span class=\"keyword\">new</span> File(dir,fileName);</div></pre></td></tr></table></figure>\n<ul>\n<li>注意一:tell浏览器该文件应该被保存,不应该被打开(部分浏览器支持该功能)</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">response.setContentType(<span class=\"string\">\"application/x-msdownload\"</span>);</div></pre></td></tr></table></figure>\n<ul>\n<li>注意二:设置下载文件的保存名称</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div></pre></td><td class=\"code\"><pre><div class=\"line\">String userAgent = request.getHeader(<span class=\"string\">\"User-Agent\"</span>);</div><div class=\"line\"><span class=\"keyword\">if</span>(userAgent.contains(<span class=\"string\">\"MSIE\"</span>)){</div><div class=\"line\"> <span class=\"comment\">//客户端使用IE浏览器</span></div><div class=\"line\"> fileName = URLEncoder.encoder(fileName,<span class=\"string\">\"UTF-8\"</span>);</div><div class=\"line\">}<span class=\"keyword\">else</span>{}</div><div class=\"line\"> <span class=\"comment\">//w3c浏览器(非IE)</span></div><div class=\"line\"> fileName = <span class=\"keyword\">new</span> String(fileName.getBytes(<span class=\"string\">\"UTF-8\"</span>),<span class=\"string\">\"ISO-8859-1\"</span>);</div><div class=\"line\">}</div><div class=\"line\">response.setHeader(<span class=\"string\">\"Content-Disposition\"</span>,<span class=\"string\">\"attachment;fileName=\"</span>+fileName);</div></pre></td></tr></table></figure>\n<p>把该文件–>写入到程序–>写出到浏览器:从服务端磁盘中拷贝到客户端的磁盘保存</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">Files.copy(Paths.get(file.getAbsolutePath()),response.getOutputStream());</div></pre></td></tr></table></figure>\n"},{"title":"简单实例之文件下载(二),基于Struts2","date":"2016-08-11T15:14:12.000Z","_content":"\n### 下载请求\n\n客户端Browser点击下载链接,基于Struts2的OGNL表达式,选择下载Java第一部\n\n``` html\n<s:a action=\"template_download?fileName=Java第一部.zip\" namespace=\"/\">Java机密第一部</s:a>\n<s:a action=\"template_download?fileName=Java第二部.zip\" namespace=\"/\">Java机密第二部</s:a>\n```\n\n### 在TemplateAction中\n\n1. filed:用于相应的文件的命名和文件下载的流,并设置setter/getter方法\n\n```java\n//给下在的文件命名\nprivate String fileName;\n//用于相应的文件下载的流\nprivate InputStream inputStreamName;\n```\n\n2. method:执行方法,设置下载文件的保存名称,调用方法:`encodeDownloadFilename()`\n\n``` java\npublic String download(){\n //获取输入流\n try {\n filePath = \"D:/workspace/.metadata/.me_tcat7/webapps/oa/WEB-INF/uploadFiles/Java第一部.zip\";\n inputStreamName = new FileInputStream(new File(filePath));\n Template template = templateService.getById(model.getId());\n //设置下载文件的保存名称\n String agent = ServletActionContext.getRequest().getHeader(\"user-agent\");\n //template.getName()得到的是文件名,在调用编码方法,显示在客户端\n fileName = this.encodeDownloadFilename(template.getName(), agent);\n } catch (Exception e) {\n e.printStackTrace();\n }\n return \"download\";\n}\n```\n\n编码的通用方法\n\n``` java\n /**\n * 下载文件时,针对不同浏览器,进行附件名的编码\n * @param filename 下载文件名\n * @param agent 客户端浏览器(通过request.getHeader(\"user-agent\")获得)\n * @return 编码后的下载附件名\n * @throws IOException\n */\npublic String encodeDownloadFilename(String filename, String agent) throws IOException{\n if(userAgent.contains(\"MSIE\")){ // IE浏览器\n filename = URLEncoder.encode(filename,\"utf-8\");\n }else{ // W3C(非IE浏览器)\n fileName = new String(fileName.getBytes(\"UTF-8\"),\"ISO-8859-1\");\n }\n return filename;\n}\n```\n\n### 在struts.xml中\n\n以下几点需要理解的:\n* result标签的name属性是\"download\"(与Action的执行方法的返回值一致)。\n* type类型须\"stream\"。\n* \"inputName\"和\"contentDisposition\"式必须下载的result必须设置的两个参数。\n* \"inputName\"参数设置的inputStreamName,是与Action中field一致的。\n* filename=\"${fileName}\",用于给下载的文件命名,也是与Action中field一致的\n\n``` xml\n<result name=\"download\" type=\"stream\">\n <param name=\"inputName\">inputStreamName</param>\n <param name=\"contentDisposition\">attachment;filename=\"${fileName}\"</param>\n</result>\n```\n","source":"_posts/简单实例之文件下载(二).md","raw":"---\ntitle: 简单实例之文件下载(二),基于Struts2\ndate: 2016-08-11 23:14:12\ncategories: 编程 \ntags: [Java]\n---\n\n### 下载请求\n\n客户端Browser点击下载链接,基于Struts2的OGNL表达式,选择下载Java第一部\n\n``` html\n<s:a action=\"template_download?fileName=Java第一部.zip\" namespace=\"/\">Java机密第一部</s:a>\n<s:a action=\"template_download?fileName=Java第二部.zip\" namespace=\"/\">Java机密第二部</s:a>\n```\n\n### 在TemplateAction中\n\n1. filed:用于相应的文件的命名和文件下载的流,并设置setter/getter方法\n\n```java\n//给下在的文件命名\nprivate String fileName;\n//用于相应的文件下载的流\nprivate InputStream inputStreamName;\n```\n\n2. method:执行方法,设置下载文件的保存名称,调用方法:`encodeDownloadFilename()`\n\n``` java\npublic String download(){\n //获取输入流\n try {\n filePath = \"D:/workspace/.metadata/.me_tcat7/webapps/oa/WEB-INF/uploadFiles/Java第一部.zip\";\n inputStreamName = new FileInputStream(new File(filePath));\n Template template = templateService.getById(model.getId());\n //设置下载文件的保存名称\n String agent = ServletActionContext.getRequest().getHeader(\"user-agent\");\n //template.getName()得到的是文件名,在调用编码方法,显示在客户端\n fileName = this.encodeDownloadFilename(template.getName(), agent);\n } catch (Exception e) {\n e.printStackTrace();\n }\n return \"download\";\n}\n```\n\n编码的通用方法\n\n``` java\n /**\n * 下载文件时,针对不同浏览器,进行附件名的编码\n * @param filename 下载文件名\n * @param agent 客户端浏览器(通过request.getHeader(\"user-agent\")获得)\n * @return 编码后的下载附件名\n * @throws IOException\n */\npublic String encodeDownloadFilename(String filename, String agent) throws IOException{\n if(userAgent.contains(\"MSIE\")){ // IE浏览器\n filename = URLEncoder.encode(filename,\"utf-8\");\n }else{ // W3C(非IE浏览器)\n fileName = new String(fileName.getBytes(\"UTF-8\"),\"ISO-8859-1\");\n }\n return filename;\n}\n```\n\n### 在struts.xml中\n\n以下几点需要理解的:\n* result标签的name属性是\"download\"(与Action的执行方法的返回值一致)。\n* type类型须\"stream\"。\n* \"inputName\"和\"contentDisposition\"式必须下载的result必须设置的两个参数。\n* \"inputName\"参数设置的inputStreamName,是与Action中field一致的。\n* filename=\"${fileName}\",用于给下载的文件命名,也是与Action中field一致的\n\n``` xml\n<result name=\"download\" type=\"stream\">\n <param name=\"inputName\">inputStreamName</param>\n <param name=\"contentDisposition\">attachment;filename=\"${fileName}\"</param>\n</result>\n```\n","slug":"简单实例之文件下载(二)","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaiev001f3sasvbb8zih0","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"下载请求\"><a href=\"#下载请求\" class=\"headerlink\" title=\"下载请求\"></a>下载请求</h3><p>客户端Browser点击下载链接,基于Struts2的OGNL表达式,选择下载Java第一部</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">s:a</span> <span class=\"attr\">action</span>=<span class=\"string\">\"template_download?fileName=Java第一部.zip\"</span> <span class=\"attr\">namespace</span>=<span class=\"string\">\"/\"</span>></span>Java机密第一部<span class=\"tag\"></<span class=\"name\">s:a</span>></span></div><div class=\"line\"><span class=\"tag\"><<span class=\"name\">s:a</span> <span class=\"attr\">action</span>=<span class=\"string\">\"template_download?fileName=Java第二部.zip\"</span> <span class=\"attr\">namespace</span>=<span class=\"string\">\"/\"</span>></span>Java机密第二部<span class=\"tag\"></<span class=\"name\">s:a</span>></span></div></pre></td></tr></table></figure>\n<h3 id=\"在TemplateAction中\"><a href=\"#在TemplateAction中\" class=\"headerlink\" title=\"在TemplateAction中\"></a>在TemplateAction中</h3><ol>\n<li>filed:用于相应的文件的命名和文件下载的流,并设置setter/getter方法</li>\n</ol>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">//给下在的文件命名</span></div><div class=\"line\"><span class=\"keyword\">private</span> String fileName;</div><div class=\"line\"><span class=\"comment\">//用于相应的文件下载的流</span></div><div class=\"line\"><span class=\"keyword\">private</span> InputStream inputStreamName;</div></pre></td></tr></table></figure>\n<ol>\n<li>method:执行方法,设置下载文件的保存名称,调用方法:<code>encodeDownloadFilename()</code></li>\n</ol>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">download</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> <span class=\"comment\">//获取输入流</span></div><div class=\"line\"> <span class=\"keyword\">try</span> {</div><div class=\"line\"> filePath = <span class=\"string\">\"D:/workspace/.metadata/.me_tcat7/webapps/oa/WEB-INF/uploadFiles/Java第一部.zip\"</span>;</div><div class=\"line\"> inputStreamName = <span class=\"keyword\">new</span> FileInputStream(<span class=\"keyword\">new</span> File(filePath));</div><div class=\"line\"> Template template = templateService.getById(model.getId());</div><div class=\"line\"> <span class=\"comment\">//设置下载文件的保存名称</span></div><div class=\"line\"> String agent = ServletActionContext.getRequest().getHeader(<span class=\"string\">\"user-agent\"</span>);</div><div class=\"line\"> <span class=\"comment\">//template.getName()得到的是文件名,在调用编码方法,显示在客户端</span></div><div class=\"line\"> fileName = <span class=\"keyword\">this</span>.encodeDownloadFilename(template.getName(), agent);</div><div class=\"line\"> } <span class=\"keyword\">catch</span> (Exception e) {</div><div class=\"line\"> e.printStackTrace();</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"string\">\"download\"</span>;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<p>编码的通用方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div></pre></td><td class=\"code\"><pre><div class=\"line\"> <span class=\"comment\">/**</span></div><div class=\"line\"> * 下载文件时,针对不同浏览器,进行附件名的编码</div><div class=\"line\"> * <span class=\"doctag\">@param</span> filename 下载文件名</div><div class=\"line\"> * <span class=\"doctag\">@param</span> agent 客户端浏览器(通过request.getHeader(\"user-agent\")获得)</div><div class=\"line\"> * <span class=\"doctag\">@return</span> 编码后的下载附件名</div><div class=\"line\"> * <span class=\"doctag\">@throws</span> IOException</div><div class=\"line\"> */</div><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">encodeDownloadFilename</span><span class=\"params\">(String filename, String agent)</span> <span class=\"keyword\">throws</span> IOException</span>{</div><div class=\"line\"> <span class=\"keyword\">if</span>(userAgent.contains(<span class=\"string\">\"MSIE\"</span>)){ <span class=\"comment\">// IE浏览器</span></div><div class=\"line\"> filename = URLEncoder.encode(filename,<span class=\"string\">\"utf-8\"</span>);</div><div class=\"line\"> }<span class=\"keyword\">else</span>{ <span class=\"comment\">// W3C(非IE浏览器)</span></div><div class=\"line\"> fileName = <span class=\"keyword\">new</span> String(fileName.getBytes(<span class=\"string\">\"UTF-8\"</span>),<span class=\"string\">\"ISO-8859-1\"</span>);</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> filename;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"在struts-xml中\"><a href=\"#在struts-xml中\" class=\"headerlink\" title=\"在struts.xml中\"></a>在struts.xml中</h3><p>以下几点需要理解的:</p>\n<ul>\n<li>result标签的name属性是”download”(与Action的执行方法的返回值一致)。</li>\n<li>type类型须”stream”。</li>\n<li>“inputName”和”contentDisposition”式必须下载的result必须设置的两个参数。</li>\n<li>“inputName”参数设置的inputStreamName,是与Action中field一致的。</li>\n<li>filename=”${fileName}”,用于给下载的文件命名,也是与Action中field一致的</li>\n</ul>\n<figure class=\"highlight xml\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">result</span> <span class=\"attr\">name</span>=<span class=\"string\">\"download\"</span> <span class=\"attr\">type</span>=<span class=\"string\">\"stream\"</span>></span></div><div class=\"line\"> <span class=\"tag\"><<span class=\"name\">param</span> <span class=\"attr\">name</span>=<span class=\"string\">\"inputName\"</span>></span>inputStreamName<span class=\"tag\"></<span class=\"name\">param</span>></span></div><div class=\"line\"> <span class=\"tag\"><<span class=\"name\">param</span> <span class=\"attr\">name</span>=<span class=\"string\">\"contentDisposition\"</span>></span>attachment;filename=\"${fileName}\"<span class=\"tag\"></<span class=\"name\">param</span>></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">result</span>></span></div></pre></td></tr></table></figure>\n","excerpt":"","more":"<h3 id=\"下载请求\"><a href=\"#下载请求\" class=\"headerlink\" title=\"下载请求\"></a>下载请求</h3><p>客户端Browser点击下载链接,基于Struts2的OGNL表达式,选择下载Java第一部</p>\n<figure class=\"highlight html\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">s:a</span> <span class=\"attr\">action</span>=<span class=\"string\">\"template_download?fileName=Java第一部.zip\"</span> <span class=\"attr\">namespace</span>=<span class=\"string\">\"/\"</span>></span>Java机密第一部<span class=\"tag\"></<span class=\"name\">s:a</span>></span></div><div class=\"line\"><span class=\"tag\"><<span class=\"name\">s:a</span> <span class=\"attr\">action</span>=<span class=\"string\">\"template_download?fileName=Java第二部.zip\"</span> <span class=\"attr\">namespace</span>=<span class=\"string\">\"/\"</span>></span>Java机密第二部<span class=\"tag\"></<span class=\"name\">s:a</span>></span></div></pre></td></tr></table></figure>\n<h3 id=\"在TemplateAction中\"><a href=\"#在TemplateAction中\" class=\"headerlink\" title=\"在TemplateAction中\"></a>在TemplateAction中</h3><ol>\n<li>filed:用于相应的文件的命名和文件下载的流,并设置setter/getter方法</li>\n</ol>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">//给下在的文件命名</span></div><div class=\"line\"><span class=\"keyword\">private</span> String fileName;</div><div class=\"line\"><span class=\"comment\">//用于相应的文件下载的流</span></div><div class=\"line\"><span class=\"keyword\">private</span> InputStream inputStreamName;</div></pre></td></tr></table></figure>\n<ol>\n<li>method:执行方法,设置下载文件的保存名称,调用方法:<code>encodeDownloadFilename()</code></li>\n</ol>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">download</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> <span class=\"comment\">//获取输入流</span></div><div class=\"line\"> <span class=\"keyword\">try</span> {</div><div class=\"line\"> filePath = <span class=\"string\">\"D:/workspace/.metadata/.me_tcat7/webapps/oa/WEB-INF/uploadFiles/Java第一部.zip\"</span>;</div><div class=\"line\"> inputStreamName = <span class=\"keyword\">new</span> FileInputStream(<span class=\"keyword\">new</span> File(filePath));</div><div class=\"line\"> Template template = templateService.getById(model.getId());</div><div class=\"line\"> <span class=\"comment\">//设置下载文件的保存名称</span></div><div class=\"line\"> String agent = ServletActionContext.getRequest().getHeader(<span class=\"string\">\"user-agent\"</span>);</div><div class=\"line\"> <span class=\"comment\">//template.getName()得到的是文件名,在调用编码方法,显示在客户端</span></div><div class=\"line\"> fileName = <span class=\"keyword\">this</span>.encodeDownloadFilename(template.getName(), agent);</div><div class=\"line\"> } <span class=\"keyword\">catch</span> (Exception e) {</div><div class=\"line\"> e.printStackTrace();</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"string\">\"download\"</span>;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<p>编码的通用方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div></pre></td><td class=\"code\"><pre><div class=\"line\"> <span class=\"comment\">/**</div><div class=\"line\"> * 下载文件时,针对不同浏览器,进行附件名的编码</div><div class=\"line\"> * <span class=\"doctag\">@param</span> filename 下载文件名</div><div class=\"line\"> * <span class=\"doctag\">@param</span> agent 客户端浏览器(通过request.getHeader(\"user-agent\")获得)</div><div class=\"line\"> * <span class=\"doctag\">@return</span> 编码后的下载附件名</div><div class=\"line\"> * <span class=\"doctag\">@throws</span> IOException</div><div class=\"line\"> */</span></div><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">encodeDownloadFilename</span><span class=\"params\">(String filename, String agent)</span> <span class=\"keyword\">throws</span> IOException</span>{</div><div class=\"line\"> <span class=\"keyword\">if</span>(userAgent.contains(<span class=\"string\">\"MSIE\"</span>)){ <span class=\"comment\">// IE浏览器</span></div><div class=\"line\"> filename = URLEncoder.encode(filename,<span class=\"string\">\"utf-8\"</span>);</div><div class=\"line\"> }<span class=\"keyword\">else</span>{ <span class=\"comment\">// W3C(非IE浏览器)</span></div><div class=\"line\"> fileName = <span class=\"keyword\">new</span> String(fileName.getBytes(<span class=\"string\">\"UTF-8\"</span>),<span class=\"string\">\"ISO-8859-1\"</span>);</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> filename;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"在struts-xml中\"><a href=\"#在struts-xml中\" class=\"headerlink\" title=\"在struts.xml中\"></a>在struts.xml中</h3><p>以下几点需要理解的:</p>\n<ul>\n<li>result标签的name属性是”download”(与Action的执行方法的返回值一致)。</li>\n<li>type类型须”stream”。</li>\n<li>“inputName”和”contentDisposition”式必须下载的result必须设置的两个参数。</li>\n<li>“inputName”参数设置的inputStreamName,是与Action中field一致的。</li>\n<li>filename=”${fileName}”,用于给下载的文件命名,也是与Action中field一致的</li>\n</ul>\n<figure class=\"highlight xml\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"tag\"><<span class=\"name\">result</span> <span class=\"attr\">name</span>=<span class=\"string\">\"download\"</span> <span class=\"attr\">type</span>=<span class=\"string\">\"stream\"</span>></span></div><div class=\"line\"> <span class=\"tag\"><<span class=\"name\">param</span> <span class=\"attr\">name</span>=<span class=\"string\">\"inputName\"</span>></span>inputStreamName<span class=\"tag\"></<span class=\"name\">param</span>></span></div><div class=\"line\"> <span class=\"tag\"><<span class=\"name\">param</span> <span class=\"attr\">name</span>=<span class=\"string\">\"contentDisposition\"</span>></span>attachment;filename=\"${fileName}\"<span class=\"tag\"></<span class=\"name\">param</span>></span></div><div class=\"line\"><span class=\"tag\"></<span class=\"name\">result</span>></span></div></pre></td></tr></table></figure>\n"},{"title":"封装json对象和解析json对象","date":"2017-06-15T02:01:26.000Z","_content":"\n### JSON语法\n> JSON(JavaScript Object Notation, JS 对象标记) 是一种轻量级的数据交换格式.JSON 简单的语法格式和清晰的层次结构明显要比 XML 容易阅读,并且在数据交换方面,由于 JSON 所使用的字符要比 XML 少得多,可以大大得节约传输数据所占用得带宽。\n\n比较常用的两种类型:\n1. 对象\n2. 数组\n\n\njson的格式:\n- 对象表示为键值对\n``` json\n{'key':'value'}\n```\n- 数据由逗号分隔\n``` json\n{'key1':'value1','key2':'value2'}\n```\n- 花括号保存对象\n``` json\n{'key1':'value1','key2':'value2',{'name':'number'}}\n```\n- 方括号保存数组\n``` json\n{'key1':'value1','key2':'value2',['Jhon:'Mach']}\n```\n\n### 组装json的方法\n##### 创建Person实体类\n\n```java\npublic class Person {\n private String name;\n private String grade;\n private String sex;\n private String birth;\n}\n```\n\n##### 组装json\n\n```java\npublic String viewMagazine(){\n Person p1 = new Person();\n person.setBirth(\"1989-22-11\");\n person.setGrade(\"07java\");\n person.setName(\"happ\");\n person.setSex(\"boy\");\n\n Person p2 = new Person();\n person1.setBirth(\"1989-22-11\");\n person1.setGrade(\"07java\");\n person1.setName(\"helloworlda\");\n person1.setSex(\"girl\");\n\n List<Person> list = new ArrayList<>();\n list.add(p1);\n list.add(p2);\n\n JSONObject json = new JSONObject();\n JSONArray arr = JSONArray.fromObject(list);//构建json数组\n json.put(\"person\",p1);//往json中添加对象\n json.put(\"personList\", list);//往json中添加list集合\n //json.put(\"personArr\", arr);//往json中添加JSONArray数组\n json.put(\"comCount\", 3);\n System.out.println(json);\n return null;\n}\n```\n\n### java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\n\n```java\nprivate static void strJsonObj(){\n String json = \"{'name':'helloworlda','array':[{'a':'111','b':'222','c':'333'},{'a':'999'}],'address':'111','people':{'name':'happ','sex':'girl'}}\";\n //将json格式的字符串转换成json对象\n JSONObject json = JSONObject.fromObject(json);\n String name = json.getString(\"name\");//字符串\n JSONArray array = json.getJSONArray(\"array\");//数组\n JSONObject people = json.getJSONObject(\"people\");//对象\n\n System.out.println(\"=======strJsonObj========\");\n System.out.println(\"name : \" + name);\n System.out.println(\"json : \" + json);\n System.out.println(\"array :\" + array);\n\n //遍历json对象:people\n Iterator<?> it = people.keys();\n while(it.hasNext){\n String key = (String)it.next().toString;\n String value = (String)people.getString(key);\n System.out.println(key + \" : \" + value);\n }\n\n //遍历json数组\n for(int i = 0; i < array.size(); i++){\n System.out.println(\"array元素 \" + i + \" : \" + array.getString(i));\n }\n}\n```\n","source":"_posts/解析json对象.md","raw":"---\ntitle: 封装json对象和解析json对象\ndate: 2017-06-15 10:01:26\ncategories: 编程 \ntags: [Java]\n---\n\n### JSON语法\n> JSON(JavaScript Object Notation, JS 对象标记) 是一种轻量级的数据交换格式.JSON 简单的语法格式和清晰的层次结构明显要比 XML 容易阅读,并且在数据交换方面,由于 JSON 所使用的字符要比 XML 少得多,可以大大得节约传输数据所占用得带宽。\n\n比较常用的两种类型:\n1. 对象\n2. 数组\n\n\njson的格式:\n- 对象表示为键值对\n``` json\n{'key':'value'}\n```\n- 数据由逗号分隔\n``` json\n{'key1':'value1','key2':'value2'}\n```\n- 花括号保存对象\n``` json\n{'key1':'value1','key2':'value2',{'name':'number'}}\n```\n- 方括号保存数组\n``` json\n{'key1':'value1','key2':'value2',['Jhon:'Mach']}\n```\n\n### 组装json的方法\n##### 创建Person实体类\n\n```java\npublic class Person {\n private String name;\n private String grade;\n private String sex;\n private String birth;\n}\n```\n\n##### 组装json\n\n```java\npublic String viewMagazine(){\n Person p1 = new Person();\n person.setBirth(\"1989-22-11\");\n person.setGrade(\"07java\");\n person.setName(\"happ\");\n person.setSex(\"boy\");\n\n Person p2 = new Person();\n person1.setBirth(\"1989-22-11\");\n person1.setGrade(\"07java\");\n person1.setName(\"helloworlda\");\n person1.setSex(\"girl\");\n\n List<Person> list = new ArrayList<>();\n list.add(p1);\n list.add(p2);\n\n JSONObject json = new JSONObject();\n JSONArray arr = JSONArray.fromObject(list);//构建json数组\n json.put(\"person\",p1);//往json中添加对象\n json.put(\"personList\", list);//往json中添加list集合\n //json.put(\"personArr\", arr);//往json中添加JSONArray数组\n json.put(\"comCount\", 3);\n System.out.println(json);\n return null;\n}\n```\n\n### java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\n\n```java\nprivate static void strJsonObj(){\n String json = \"{'name':'helloworlda','array':[{'a':'111','b':'222','c':'333'},{'a':'999'}],'address':'111','people':{'name':'happ','sex':'girl'}}\";\n //将json格式的字符串转换成json对象\n JSONObject json = JSONObject.fromObject(json);\n String name = json.getString(\"name\");//字符串\n JSONArray array = json.getJSONArray(\"array\");//数组\n JSONObject people = json.getJSONObject(\"people\");//对象\n\n System.out.println(\"=======strJsonObj========\");\n System.out.println(\"name : \" + name);\n System.out.println(\"json : \" + json);\n System.out.println(\"array :\" + array);\n\n //遍历json对象:people\n Iterator<?> it = people.keys();\n while(it.hasNext){\n String key = (String)it.next().toString;\n String value = (String)people.getString(key);\n System.out.println(key + \" : \" + value);\n }\n\n //遍历json数组\n for(int i = 0; i < array.size(); i++){\n System.out.println(\"array元素 \" + i + \" : \" + array.getString(i));\n }\n}\n```\n","slug":"解析json对象","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaiex001j3saslwtp9xhr","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"JSON语法\"><a href=\"#JSON语法\" class=\"headerlink\" title=\"JSON语法\"></a>JSON语法</h3><blockquote>\n<p>JSON(JavaScript Object Notation, JS 对象标记) 是一种轻量级的数据交换格式.JSON 简单的语法格式和清晰的层次结构明显要比 XML 容易阅读,并且在数据交换方面,由于 JSON 所使用的字符要比 XML 少得多,可以大大得节约传输数据所占用得带宽。</p>\n</blockquote>\n<p>比较常用的两种类型:</p>\n<ol>\n<li>对象</li>\n<li>数组</li>\n</ol>\n<p>json的格式:</p>\n<ul>\n<li><p>对象表示为键值对</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key':'value'}</div></pre></td></tr></table></figure>\n</li>\n<li><p>数据由逗号分隔</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key1':'value1','key2':'value2'}</div></pre></td></tr></table></figure>\n</li>\n<li><p>花括号保存对象</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key1':'value1','key2':'value2',{'name':'number'}}</div></pre></td></tr></table></figure>\n</li>\n<li><p>方括号保存数组</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key1':'value1','key2':'value2',['Jhon:'Mach']}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"组装json的方法\"><a href=\"#组装json的方法\" class=\"headerlink\" title=\"组装json的方法\"></a>组装json的方法</h3><h5 id=\"创建Person实体类\"><a href=\"#创建Person实体类\" class=\"headerlink\" title=\"创建Person实体类\"></a>创建Person实体类</h5><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">Person</span> </span>{</div><div class=\"line\"> <span class=\"keyword\">private</span> String name;</div><div class=\"line\"> <span class=\"keyword\">private</span> String grade;</div><div class=\"line\"> <span class=\"keyword\">private</span> String sex;</div><div class=\"line\"> <span class=\"keyword\">private</span> String birth;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h5 id=\"组装json\"><a href=\"#组装json\" class=\"headerlink\" title=\"组装json\"></a>组装json</h5><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">viewMagazine</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> Person p1 = <span class=\"keyword\">new</span> Person();</div><div class=\"line\"> person.setBirth(<span class=\"string\">\"1989-22-11\"</span>);</div><div class=\"line\"> person.setGrade(<span class=\"string\">\"07java\"</span>);</div><div class=\"line\"> person.setName(<span class=\"string\">\"happ\"</span>);</div><div class=\"line\"> person.setSex(<span class=\"string\">\"boy\"</span>);</div><div class=\"line\"></div><div class=\"line\"> Person p2 = <span class=\"keyword\">new</span> Person();</div><div class=\"line\"> person1.setBirth(<span class=\"string\">\"1989-22-11\"</span>);</div><div class=\"line\"> person1.setGrade(<span class=\"string\">\"07java\"</span>);</div><div class=\"line\"> person1.setName(<span class=\"string\">\"helloworlda\"</span>);</div><div class=\"line\"> person1.setSex(<span class=\"string\">\"girl\"</span>);</div><div class=\"line\"></div><div class=\"line\"> List<Person> list = <span class=\"keyword\">new</span> ArrayList<>();</div><div class=\"line\"> list.add(p1);</div><div class=\"line\"> list.add(p2);</div><div class=\"line\"></div><div class=\"line\"> JSONObject json = <span class=\"keyword\">new</span> JSONObject();</div><div class=\"line\"> JSONArray arr = JSONArray.fromObject(list);<span class=\"comment\">//构建json数组</span></div><div class=\"line\"> json.put(<span class=\"string\">\"person\"</span>,p1);<span class=\"comment\">//往json中添加对象</span></div><div class=\"line\"> json.put(<span class=\"string\">\"personList\"</span>, list);<span class=\"comment\">//往json中添加list集合</span></div><div class=\"line\"> <span class=\"comment\">//json.put(\"personArr\", arr);//往json中添加JSONArray数组</span></div><div class=\"line\"> json.put(<span class=\"string\">\"comCount\"</span>, <span class=\"number\">3</span>);</div><div class=\"line\"> System.out.println(json);</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"keyword\">null</span>;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\"><a href=\"#java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\" class=\"headerlink\" title=\"java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\"></a>java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">private</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">strJsonObj</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> String json = <span class=\"string\">\"{'name':'helloworlda','array':[{'a':'111','b':'222','c':'333'},{'a':'999'}],'address':'111','people':{'name':'happ','sex':'girl'}}\"</span>;</div><div class=\"line\"> <span class=\"comment\">//将json格式的字符串转换成json对象</span></div><div class=\"line\"> JSONObject json = JSONObject.fromObject(json);</div><div class=\"line\"> String name = json.getString(<span class=\"string\">\"name\"</span>);<span class=\"comment\">//字符串</span></div><div class=\"line\"> JSONArray array = json.getJSONArray(<span class=\"string\">\"array\"</span>);<span class=\"comment\">//数组</span></div><div class=\"line\"> JSONObject people = json.getJSONObject(<span class=\"string\">\"people\"</span>);<span class=\"comment\">//对象</span></div><div class=\"line\"></div><div class=\"line\"> System.out.println(<span class=\"string\">\"=======strJsonObj========\"</span>);</div><div class=\"line\"> System.out.println(<span class=\"string\">\"name : \"</span> + name);</div><div class=\"line\"> System.out.println(<span class=\"string\">\"json : \"</span> + json);</div><div class=\"line\"> System.out.println(<span class=\"string\">\"array :\"</span> + array);</div><div class=\"line\"></div><div class=\"line\"> <span class=\"comment\">//遍历json对象:people</span></div><div class=\"line\"> Iterator<?> it = people.keys();</div><div class=\"line\"> <span class=\"keyword\">while</span>(it.hasNext){</div><div class=\"line\"> String key = (String)it.next().toString;</div><div class=\"line\"> String value = (String)people.getString(key);</div><div class=\"line\"> System.out.println(key + <span class=\"string\">\" : \"</span> + value);</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"comment\">//遍历json数组</span></div><div class=\"line\"> <span class=\"keyword\">for</span>(<span class=\"keyword\">int</span> i = <span class=\"number\">0</span>; i < array.size(); i++){</div><div class=\"line\"> System.out.println(<span class=\"string\">\"array元素 \"</span> + i + <span class=\"string\">\" : \"</span> + array.getString(i));</div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n","excerpt":"","more":"<h3 id=\"JSON语法\"><a href=\"#JSON语法\" class=\"headerlink\" title=\"JSON语法\"></a>JSON语法</h3><blockquote>\n<p>JSON(JavaScript Object Notation, JS 对象标记) 是一种轻量级的数据交换格式.JSON 简单的语法格式和清晰的层次结构明显要比 XML 容易阅读,并且在数据交换方面,由于 JSON 所使用的字符要比 XML 少得多,可以大大得节约传输数据所占用得带宽。</p>\n</blockquote>\n<p>比较常用的两种类型:</p>\n<ol>\n<li>对象</li>\n<li>数组</li>\n</ol>\n<p>json的格式:</p>\n<ul>\n<li><p>对象表示为键值对</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key':'value'}</div></pre></td></tr></table></figure>\n</li>\n<li><p>数据由逗号分隔</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key1':'value1','key2':'value2'}</div></pre></td></tr></table></figure>\n</li>\n<li><p>花括号保存对象</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key1':'value1','key2':'value2',{'name':'number'}}</div></pre></td></tr></table></figure>\n</li>\n<li><p>方括号保存数组</p>\n<figure class=\"highlight\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\">{'key1':'value1','key2':'value2',['Jhon:'Mach']}</div></pre></td></tr></table></figure>\n</li>\n</ul>\n<h3 id=\"组装json的方法\"><a href=\"#组装json的方法\" class=\"headerlink\" title=\"组装json的方法\"></a>组装json的方法</h3><h5 id=\"创建Person实体类\"><a href=\"#创建Person实体类\" class=\"headerlink\" title=\"创建Person实体类\"></a>创建Person实体类</h5><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">Person</span> </span>{</div><div class=\"line\"> <span class=\"keyword\">private</span> String name;</div><div class=\"line\"> <span class=\"keyword\">private</span> String grade;</div><div class=\"line\"> <span class=\"keyword\">private</span> String sex;</div><div class=\"line\"> <span class=\"keyword\">private</span> String birth;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h5 id=\"组装json\"><a href=\"#组装json\" class=\"headerlink\" title=\"组装json\"></a>组装json</h5><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> String <span class=\"title\">viewMagazine</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> Person p1 = <span class=\"keyword\">new</span> Person();</div><div class=\"line\"> person.setBirth(<span class=\"string\">\"1989-22-11\"</span>);</div><div class=\"line\"> person.setGrade(<span class=\"string\">\"07java\"</span>);</div><div class=\"line\"> person.setName(<span class=\"string\">\"happ\"</span>);</div><div class=\"line\"> person.setSex(<span class=\"string\">\"boy\"</span>);</div><div class=\"line\"></div><div class=\"line\"> Person p2 = <span class=\"keyword\">new</span> Person();</div><div class=\"line\"> person1.setBirth(<span class=\"string\">\"1989-22-11\"</span>);</div><div class=\"line\"> person1.setGrade(<span class=\"string\">\"07java\"</span>);</div><div class=\"line\"> person1.setName(<span class=\"string\">\"helloworlda\"</span>);</div><div class=\"line\"> person1.setSex(<span class=\"string\">\"girl\"</span>);</div><div class=\"line\"></div><div class=\"line\"> List<Person> list = <span class=\"keyword\">new</span> ArrayList<>();</div><div class=\"line\"> list.add(p1);</div><div class=\"line\"> list.add(p2);</div><div class=\"line\"></div><div class=\"line\"> JSONObject json = <span class=\"keyword\">new</span> JSONObject();</div><div class=\"line\"> JSONArray arr = JSONArray.fromObject(list);<span class=\"comment\">//构建json数组</span></div><div class=\"line\"> json.put(<span class=\"string\">\"person\"</span>,p1);<span class=\"comment\">//往json中添加对象</span></div><div class=\"line\"> json.put(<span class=\"string\">\"personList\"</span>, list);<span class=\"comment\">//往json中添加list集合</span></div><div class=\"line\"> <span class=\"comment\">//json.put(\"personArr\", arr);//往json中添加JSONArray数组</span></div><div class=\"line\"> json.put(<span class=\"string\">\"comCount\"</span>, <span class=\"number\">3</span>);</div><div class=\"line\"> System.out.println(json);</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"keyword\">null</span>;</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h3 id=\"java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\"><a href=\"#java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\" class=\"headerlink\" title=\"java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值\"></a>java解析json对象,解析出对象、字符串以及数组,然后遍历出相应的值</h3><figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"function\"><span class=\"keyword\">private</span> <span class=\"keyword\">static</span> <span class=\"keyword\">void</span> <span class=\"title\">strJsonObj</span><span class=\"params\">()</span></span>{</div><div class=\"line\"> String json = <span class=\"string\">\"{'name':'helloworlda','array':[{'a':'111','b':'222','c':'333'},{'a':'999'}],'address':'111','people':{'name':'happ','sex':'girl'}}\"</span>;</div><div class=\"line\"> <span class=\"comment\">//将json格式的字符串转换成json对象</span></div><div class=\"line\"> JSONObject json = JSONObject.fromObject(json);</div><div class=\"line\"> String name = json.getString(<span class=\"string\">\"name\"</span>);<span class=\"comment\">//字符串</span></div><div class=\"line\"> JSONArray array = json.getJSONArray(<span class=\"string\">\"array\"</span>);<span class=\"comment\">//数组</span></div><div class=\"line\"> JSONObject people = json.getJSONObject(<span class=\"string\">\"people\"</span>);<span class=\"comment\">//对象</span></div><div class=\"line\"></div><div class=\"line\"> System.out.println(<span class=\"string\">\"=======strJsonObj========\"</span>);</div><div class=\"line\"> System.out.println(<span class=\"string\">\"name : \"</span> + name);</div><div class=\"line\"> System.out.println(<span class=\"string\">\"json : \"</span> + json);</div><div class=\"line\"> System.out.println(<span class=\"string\">\"array :\"</span> + array);</div><div class=\"line\"></div><div class=\"line\"> <span class=\"comment\">//遍历json对象:people</span></div><div class=\"line\"> Iterator<?> it = people.keys();</div><div class=\"line\"> <span class=\"keyword\">while</span>(it.hasNext){</div><div class=\"line\"> String key = (String)it.next().toString;</div><div class=\"line\"> String value = (String)people.getString(key);</div><div class=\"line\"> System.out.println(key + <span class=\"string\">\" : \"</span> + value);</div><div class=\"line\"> }</div><div class=\"line\"></div><div class=\"line\"> <span class=\"comment\">//遍历json数组</span></div><div class=\"line\"> <span class=\"keyword\">for</span>(<span class=\"keyword\">int</span> i = <span class=\"number\">0</span>; i < array.size(); i++){</div><div class=\"line\"> System.out.println(<span class=\"string\">\"array元素 \"</span> + i + <span class=\"string\">\" : \"</span> + array.getString(i));</div><div class=\"line\"> }</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n"},{"title":"条件查询和分页原理(二)","date":"2016-08-22T16:18:32.000Z","_content":"\n### 分页原理--准备\n\n- 需要客户端设定的数据\n\n``` java\ncurrentPage = 1//当前页\npageSize = 10//每页最多多少条数据\n```\n\n- 需要到数据库查询出来的数据\n1. 第一条SQL:查询符合条件的结果总数(totalCount).\n\n``` sql\nselect COUNT(*) from tableName [where 条件];\n```\n2. 第二条SQL:查询符合条件的结果集.\nbeginIndex:从哪一条数据的索引开始截取(从0开始).\nbeginIndex = (currentPage - 1) * pageSize;\npageSize:每次截取多少条数据.\n\n``` sql\nselect * from tableName [ where 条件] limit beginIndex,pageSize;\n```\n\n### 封装分页结果集对象:PageBean\n\n备注:分页结果集对象的field,只需实现getter方法\n\n``` java\n/**\n * 分页的实体\n * @author bubblelin\n */\npublic class PageBean {\n //需要客户端(用户)设定的数据,只需实现getter方法\n\tprivate Integer currentPage;\n\tprivate Integer pageCount;\n //需要到数据库查询出来的数据,只需实现getter方法\n\tprivate Integer totalCount;\n\tprivate List listData;\n //通过前面四个数据计算得到,只需实现getter方法\n\tprivate Integer totalPage;\n\tprivate Integer beginPage;\n\tprivate Integer prevPage;\n\tprivate Integer nextPage;\n\n\tpublic PageBean() {\n\t}\n\n\tpublic PageBean(Integer currentPage, Integer pageCount, Integer totalCount,\n\t\t\tList listData) {\n\t\tthis.currentPage = currentPage;\n\t\tthis.pageCount = pageCount;\n\t\tthis.totalCount = totalCount;\n\t\tthis.listData = listData;\n //计算得到总页数\n\t\tthis.totalPage = this.totalCount % this.pageCount == 0\n\t\t\t\t? this.totalCount / this.pageCount : this.totalCount / this.pageCount + 1;\n //首页一般是第一页\n\t\tthis.beginPage = 1;\n //计算得到上页和下页\n\t\tthis.prevPage = this.currentPage - 1 > 0 ? this.currentPage - 1 : this.beginPage;\n\t\tthis.nextPage = this.currentPage + 1 < this.totalPage ? this.currentPage + 1 : this.totalPage;\n\t}\n\n```\n\n\n### 分页方法的实现\n\n备注:`JdbcTemplate.executeQuery()`未数据库查询方法\n\n``` java\n/**\n * 分页方法\n */\npublic PageBean<Product> page(Integer currentPage, Integer pageSize) {\n //查询当前页的结果\n String baseSql = \"SELECT * FROM product LIMIT ?,?\";\n List<Product> listData = JdbcTemplate.executeQuery()(baseSql,new ResultSetHandlerProduct(),(currentPage - 1) * pageSize,pageSize);\n //查询结果总数\n String CountSql = \"SELECT COUNT(*) FROM product\";\n Integer totalCount = JdbcTemplate.executeQuery()(CountSql, new IResultSetHandler<Long>() {\n @Override\n public Long handler(ResultSet rs) throws Exception {\n if(rs.next()){\n return rs.getLong(1);\n }\n return 0L;\n }\n }).intValue();\n //返回分页结果集\n return new PageBean<>(listData, totalCount, currentPage, pageSize);\n}\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## re\n","source":"_posts/条件查询和分页原理到底是怎么样的(二).md","raw":"---\ntitle: 条件查询和分页原理(二)\ndate: 2016-08-23 00:18:32\ncategories: 编程 \ntags: [Java] \n---\n\n### 分页原理--准备\n\n- 需要客户端设定的数据\n\n``` java\ncurrentPage = 1//当前页\npageSize = 10//每页最多多少条数据\n```\n\n- 需要到数据库查询出来的数据\n1. 第一条SQL:查询符合条件的结果总数(totalCount).\n\n``` sql\nselect COUNT(*) from tableName [where 条件];\n```\n2. 第二条SQL:查询符合条件的结果集.\nbeginIndex:从哪一条数据的索引开始截取(从0开始).\nbeginIndex = (currentPage - 1) * pageSize;\npageSize:每次截取多少条数据.\n\n``` sql\nselect * from tableName [ where 条件] limit beginIndex,pageSize;\n```\n\n### 封装分页结果集对象:PageBean\n\n备注:分页结果集对象的field,只需实现getter方法\n\n``` java\n/**\n * 分页的实体\n * @author bubblelin\n */\npublic class PageBean {\n //需要客户端(用户)设定的数据,只需实现getter方法\n\tprivate Integer currentPage;\n\tprivate Integer pageCount;\n //需要到数据库查询出来的数据,只需实现getter方法\n\tprivate Integer totalCount;\n\tprivate List listData;\n //通过前面四个数据计算得到,只需实现getter方法\n\tprivate Integer totalPage;\n\tprivate Integer beginPage;\n\tprivate Integer prevPage;\n\tprivate Integer nextPage;\n\n\tpublic PageBean() {\n\t}\n\n\tpublic PageBean(Integer currentPage, Integer pageCount, Integer totalCount,\n\t\t\tList listData) {\n\t\tthis.currentPage = currentPage;\n\t\tthis.pageCount = pageCount;\n\t\tthis.totalCount = totalCount;\n\t\tthis.listData = listData;\n //计算得到总页数\n\t\tthis.totalPage = this.totalCount % this.pageCount == 0\n\t\t\t\t? this.totalCount / this.pageCount : this.totalCount / this.pageCount + 1;\n //首页一般是第一页\n\t\tthis.beginPage = 1;\n //计算得到上页和下页\n\t\tthis.prevPage = this.currentPage - 1 > 0 ? this.currentPage - 1 : this.beginPage;\n\t\tthis.nextPage = this.currentPage + 1 < this.totalPage ? this.currentPage + 1 : this.totalPage;\n\t}\n\n```\n\n\n### 分页方法的实现\n\n备注:`JdbcTemplate.executeQuery()`未数据库查询方法\n\n``` java\n/**\n * 分页方法\n */\npublic PageBean<Product> page(Integer currentPage, Integer pageSize) {\n //查询当前页的结果\n String baseSql = \"SELECT * FROM product LIMIT ?,?\";\n List<Product> listData = JdbcTemplate.executeQuery()(baseSql,new ResultSetHandlerProduct(),(currentPage - 1) * pageSize,pageSize);\n //查询结果总数\n String CountSql = \"SELECT COUNT(*) FROM product\";\n Integer totalCount = JdbcTemplate.executeQuery()(CountSql, new IResultSetHandler<Long>() {\n @Override\n public Long handler(ResultSet rs) throws Exception {\n if(rs.next()){\n return rs.getLong(1);\n }\n return 0L;\n }\n }).intValue();\n //返回分页结果集\n return new PageBean<>(listData, totalCount, currentPage, pageSize);\n}\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## re\n","slug":"条件查询和分页原理到底是怎么样的(二)","published":1,"updated":"2018-01-10T03:20:19.000Z","comments":1,"layout":"post","photos":[],"link":"","_id":"cjc8oaif2001m3sasvwus3g4q","content":"<script src=\"/assets/js/DPlayer.min.js\"> </script><script src=\"/assets/js/APlayer.min.js\"> </script><h3 id=\"分页原理–准备\"><a href=\"#分页原理–准备\" class=\"headerlink\" title=\"分页原理–准备\"></a>分页原理–准备</h3><ul>\n<li>需要客户端设定的数据</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">currentPage = <span class=\"number\">1</span><span class=\"comment\">//当前页</span></div><div class=\"line\">pageSize = <span class=\"number\">10</span><span class=\"comment\">//每页最多多少条数据</span></div></pre></td></tr></table></figure>\n<ul>\n<li>需要到数据库查询出来的数据</li>\n</ul>\n<ol>\n<li>第一条SQL:查询符合条件的结果总数(totalCount).</li>\n</ol>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span> <span class=\"keyword\">COUNT</span>(*) <span class=\"keyword\">from</span> tableName [<span class=\"keyword\">where</span> 条件];</div></pre></td></tr></table></figure>\n<ol>\n<li>第二条SQL:查询符合条件的结果集.<br>beginIndex:从哪一条数据的索引开始截取(从0开始).<br>beginIndex = (currentPage - 1) * pageSize;<br>pageSize:每次截取多少条数据.</li>\n</ol>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span> * <span class=\"keyword\">from</span> tableName [ <span class=\"keyword\">where</span> 条件] <span class=\"keyword\">limit</span> beginIndex,pageSize;</div></pre></td></tr></table></figure>\n<h3 id=\"封装分页结果集对象:PageBean\"><a href=\"#封装分页结果集对象:PageBean\" class=\"headerlink\" title=\"封装分页结果集对象:PageBean\"></a>封装分页结果集对象:PageBean</h3><p>备注:分页结果集对象的field,只需实现getter方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div><div class=\"line\">27</div><div class=\"line\">28</div><div class=\"line\">29</div><div class=\"line\">30</div><div class=\"line\">31</div><div class=\"line\">32</div><div class=\"line\">33</div><div class=\"line\">34</div><div class=\"line\">35</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</span></div><div class=\"line\"> * 分页的实体</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> */</div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">PageBean</span> </span>{</div><div class=\"line\"> <span class=\"comment\">//需要客户端(用户)设定的数据,只需实现getter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer currentPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer pageCount;</div><div class=\"line\"> <span class=\"comment\">//需要到数据库查询出来的数据,只需实现getter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer totalCount;</div><div class=\"line\">\t<span class=\"keyword\">private</span> List listData;</div><div class=\"line\"> <span class=\"comment\">//通过前面四个数据计算得到,只需实现getter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer totalPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer beginPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer prevPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer nextPage;</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> <span class=\"title\">PageBean</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t}</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> <span class=\"title\">PageBean</span><span class=\"params\">(Integer currentPage, Integer pageCount, Integer totalCount,</span></span></div><div class=\"line\">\t\t\tList listData) {</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.currentPage = currentPage;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.pageCount = pageCount;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.totalCount = totalCount;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.listData = listData;</div><div class=\"line\"> <span class=\"comment\">//计算得到总页数</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.totalPage = <span class=\"keyword\">this</span>.totalCount % <span class=\"keyword\">this</span>.pageCount == <span class=\"number\">0</span></div><div class=\"line\">\t\t\t\t? <span class=\"keyword\">this</span>.totalCount / <span class=\"keyword\">this</span>.pageCount : <span class=\"keyword\">this</span>.totalCount / <span class=\"keyword\">this</span>.pageCount + <span class=\"number\">1</span>;</div><div class=\"line\"> <span class=\"comment\">//首页一般是第一页</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.beginPage = <span class=\"number\">1</span>;</div><div class=\"line\"> <span class=\"comment\">//计算得到上页和下页</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.prevPage = <span class=\"keyword\">this</span>.currentPage - <span class=\"number\">1</span> > <span class=\"number\">0</span> ? <span class=\"keyword\">this</span>.currentPage - <span class=\"number\">1</span> : <span class=\"keyword\">this</span>.beginPage;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.nextPage = <span class=\"keyword\">this</span>.currentPage + <span class=\"number\">1</span> < <span class=\"keyword\">this</span>.totalPage ? <span class=\"keyword\">this</span>.currentPage + <span class=\"number\">1</span> : <span class=\"keyword\">this</span>.totalPage;</div><div class=\"line\">\t}</div></pre></td></tr></table></figure>\n<h3 id=\"分页方法的实现\"><a href=\"#分页方法的实现\" class=\"headerlink\" title=\"分页方法的实现\"></a>分页方法的实现</h3><p>备注:<code>JdbcTemplate.executeQuery()</code>未数据库查询方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</span></div><div class=\"line\"> * 分页方法</div><div class=\"line\"> */</div><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> PageBean<Product> <span class=\"title\">page</span><span class=\"params\">(Integer currentPage, Integer pageSize)</span> </span>{</div><div class=\"line\"> <span class=\"comment\">//查询当前页的结果</span></div><div class=\"line\"> String baseSql = <span class=\"string\">\"SELECT * FROM product LIMIT ?,?\"</span>;</div><div class=\"line\"> List<Product> listData = JdbcTemplate.executeQuery()(baseSql,<span class=\"keyword\">new</span> ResultSetHandlerProduct(),(currentPage - <span class=\"number\">1</span>) * pageSize,pageSize);</div><div class=\"line\"> <span class=\"comment\">//查询结果总数</span></div><div class=\"line\"> String CountSql = <span class=\"string\">\"SELECT COUNT(*) FROM product\"</span>;</div><div class=\"line\"> Integer totalCount = JdbcTemplate.executeQuery()(CountSql, <span class=\"keyword\">new</span> IResultSetHandler<Long>() {</div><div class=\"line\"> <span class=\"meta\">@Override</span></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> Long <span class=\"title\">handler</span><span class=\"params\">(ResultSet rs)</span> <span class=\"keyword\">throws</span> Exception </span>{</div><div class=\"line\"> <span class=\"keyword\">if</span>(rs.next()){</div><div class=\"line\"> <span class=\"keyword\">return</span> rs.getLong(<span class=\"number\">1</span>);</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"number\">0L</span>;</div><div class=\"line\"> }</div><div class=\"line\"> }).intValue();</div><div class=\"line\"> <span class=\"comment\">//返回分页结果集</span></div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"keyword\">new</span> PageBean<>(listData, totalCount, currentPage, pageSize);</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h2 id=\"re\"><a href=\"#re\" class=\"headerlink\" title=\"re\"></a>re</h2>","excerpt":"","more":"<h3 id=\"分页原理–准备\"><a href=\"#分页原理–准备\" class=\"headerlink\" title=\"分页原理–准备\"></a>分页原理–准备</h3><ul>\n<li>需要客户端设定的数据</li>\n</ul>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div></pre></td><td class=\"code\"><pre><div class=\"line\">currentPage = <span class=\"number\">1</span><span class=\"comment\">//当前页</span></div><div class=\"line\">pageSize = <span class=\"number\">10</span><span class=\"comment\">//每页最多多少条数据</span></div></pre></td></tr></table></figure>\n<ul>\n<li>需要到数据库查询出来的数据</li>\n</ul>\n<ol>\n<li>第一条SQL:查询符合条件的结果总数(totalCount).</li>\n</ol>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span> <span class=\"keyword\">COUNT</span>(*) <span class=\"keyword\">from</span> tableName [<span class=\"keyword\">where</span> 条件];</div></pre></td></tr></table></figure>\n<ol>\n<li>第二条SQL:查询符合条件的结果集.<br>beginIndex:从哪一条数据的索引开始截取(从0开始).<br>beginIndex = (currentPage - 1) * pageSize;<br>pageSize:每次截取多少条数据.</li>\n</ol>\n<figure class=\"highlight sql\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"keyword\">select</span> * <span class=\"keyword\">from</span> tableName [ <span class=\"keyword\">where</span> 条件] <span class=\"keyword\">limit</span> beginIndex,pageSize;</div></pre></td></tr></table></figure>\n<h3 id=\"封装分页结果集对象:PageBean\"><a href=\"#封装分页结果集对象:PageBean\" class=\"headerlink\" title=\"封装分页结果集对象:PageBean\"></a>封装分页结果集对象:PageBean</h3><p>备注:分页结果集对象的field,只需实现getter方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div><div class=\"line\">22</div><div class=\"line\">23</div><div class=\"line\">24</div><div class=\"line\">25</div><div class=\"line\">26</div><div class=\"line\">27</div><div class=\"line\">28</div><div class=\"line\">29</div><div class=\"line\">30</div><div class=\"line\">31</div><div class=\"line\">32</div><div class=\"line\">33</div><div class=\"line\">34</div><div class=\"line\">35</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</div><div class=\"line\"> * 分页的实体</div><div class=\"line\"> * <span class=\"doctag\">@author</span> bubblelin</div><div class=\"line\"> */</span></div><div class=\"line\"><span class=\"keyword\">public</span> <span class=\"class\"><span class=\"keyword\">class</span> <span class=\"title\">PageBean</span> </span>{</div><div class=\"line\"> <span class=\"comment\">//需要客户端(用户)设定的数据,只需实现getter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer currentPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer pageCount;</div><div class=\"line\"> <span class=\"comment\">//需要到数据库查询出来的数据,只需实现getter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer totalCount;</div><div class=\"line\">\t<span class=\"keyword\">private</span> List listData;</div><div class=\"line\"> <span class=\"comment\">//通过前面四个数据计算得到,只需实现getter方法</span></div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer totalPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer beginPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer prevPage;</div><div class=\"line\">\t<span class=\"keyword\">private</span> Integer nextPage;</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> <span class=\"title\">PageBean</span><span class=\"params\">()</span> </span>{</div><div class=\"line\">\t}</div><div class=\"line\"></div><div class=\"line\">\t<span class=\"function\"><span class=\"keyword\">public</span> <span class=\"title\">PageBean</span><span class=\"params\">(Integer currentPage, Integer pageCount, Integer totalCount,</div><div class=\"line\">\t\t\tList listData)</span> </span>{</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.currentPage = currentPage;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.pageCount = pageCount;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.totalCount = totalCount;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.listData = listData;</div><div class=\"line\"> <span class=\"comment\">//计算得到总页数</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.totalPage = <span class=\"keyword\">this</span>.totalCount % <span class=\"keyword\">this</span>.pageCount == <span class=\"number\">0</span></div><div class=\"line\">\t\t\t\t? <span class=\"keyword\">this</span>.totalCount / <span class=\"keyword\">this</span>.pageCount : <span class=\"keyword\">this</span>.totalCount / <span class=\"keyword\">this</span>.pageCount + <span class=\"number\">1</span>;</div><div class=\"line\"> <span class=\"comment\">//首页一般是第一页</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.beginPage = <span class=\"number\">1</span>;</div><div class=\"line\"> <span class=\"comment\">//计算得到上页和下页</span></div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.prevPage = <span class=\"keyword\">this</span>.currentPage - <span class=\"number\">1</span> > <span class=\"number\">0</span> ? <span class=\"keyword\">this</span>.currentPage - <span class=\"number\">1</span> : <span class=\"keyword\">this</span>.beginPage;</div><div class=\"line\">\t\t<span class=\"keyword\">this</span>.nextPage = <span class=\"keyword\">this</span>.currentPage + <span class=\"number\">1</span> < <span class=\"keyword\">this</span>.totalPage ? <span class=\"keyword\">this</span>.currentPage + <span class=\"number\">1</span> : <span class=\"keyword\">this</span>.totalPage;</div><div class=\"line\">\t}</div></pre></td></tr></table></figure>\n<h3 id=\"分页方法的实现\"><a href=\"#分页方法的实现\" class=\"headerlink\" title=\"分页方法的实现\"></a>分页方法的实现</h3><p>备注:<code>JdbcTemplate.executeQuery()</code>未数据库查询方法</p>\n<figure class=\"highlight java\"><table><tr><td class=\"gutter\"><pre><div class=\"line\">1</div><div class=\"line\">2</div><div class=\"line\">3</div><div class=\"line\">4</div><div class=\"line\">5</div><div class=\"line\">6</div><div class=\"line\">7</div><div class=\"line\">8</div><div class=\"line\">9</div><div class=\"line\">10</div><div class=\"line\">11</div><div class=\"line\">12</div><div class=\"line\">13</div><div class=\"line\">14</div><div class=\"line\">15</div><div class=\"line\">16</div><div class=\"line\">17</div><div class=\"line\">18</div><div class=\"line\">19</div><div class=\"line\">20</div><div class=\"line\">21</div></pre></td><td class=\"code\"><pre><div class=\"line\"><span class=\"comment\">/**</div><div class=\"line\"> * 分页方法</div><div class=\"line\"> */</span></div><div class=\"line\"><span class=\"function\"><span class=\"keyword\">public</span> PageBean<Product> <span class=\"title\">page</span><span class=\"params\">(Integer currentPage, Integer pageSize)</span> </span>{</div><div class=\"line\"> <span class=\"comment\">//查询当前页的结果</span></div><div class=\"line\"> String baseSql = <span class=\"string\">\"SELECT * FROM product LIMIT ?,?\"</span>;</div><div class=\"line\"> List<Product> listData = JdbcTemplate.executeQuery()(baseSql,<span class=\"keyword\">new</span> ResultSetHandlerProduct(),(currentPage - <span class=\"number\">1</span>) * pageSize,pageSize);</div><div class=\"line\"> <span class=\"comment\">//查询结果总数</span></div><div class=\"line\"> String CountSql = <span class=\"string\">\"SELECT COUNT(*) FROM product\"</span>;</div><div class=\"line\"> Integer totalCount = JdbcTemplate.executeQuery()(CountSql, <span class=\"keyword\">new</span> IResultSetHandler<Long>() {</div><div class=\"line\"> <span class=\"meta\">@Override</span></div><div class=\"line\"> <span class=\"function\"><span class=\"keyword\">public</span> Long <span class=\"title\">handler</span><span class=\"params\">(ResultSet rs)</span> <span class=\"keyword\">throws</span> Exception </span>{</div><div class=\"line\"> <span class=\"keyword\">if</span>(rs.next()){</div><div class=\"line\"> <span class=\"keyword\">return</span> rs.getLong(<span class=\"number\">1</span>);</div><div class=\"line\"> }</div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"number\">0L</span>;</div><div class=\"line\"> }</div><div class=\"line\"> }).intValue();</div><div class=\"line\"> <span class=\"comment\">//返回分页结果集</span></div><div class=\"line\"> <span class=\"keyword\">return</span> <span class=\"keyword\">new</span> PageBean<>(listData, totalCount, currentPage, pageSize);</div><div class=\"line\">}</div></pre></td></tr></table></figure>\n<h2 id=\"re\"><a href=\"#re\" class=\"headerlink\" title=\"re\"></a>re</h2>"}],"PostAsset":[],"PostCategory":[{"post_id":"cjc8oaida00003sas1kvf2kvd","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaie3000e3sasreogtbl5"},{"post_id":"cjc8oaidg00023saszs7qpv82","category_id":"cjc8oaie0000b3saseatt3hnh","_id":"cjc8oaieb000k3sas5lbfotx3"},{"post_id":"cjc8oaie4000f3sasckzf13fa","category_id":"cjc8oaie0000b3saseatt3hnh","_id":"cjc8oaied000p3sasntlm303h"},{"post_id":"cjc8oaie7000i3sasemads3e2","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaiei000s3sase8t02mzv"},{"post_id":"cjc8oaids00063sas2dedzcm0","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaiel000x3saslpd19gg2"},{"post_id":"cjc8oaie9000j3sasd8fe17d8","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaien00103sasrkroidbw"},{"post_id":"cjc8oaidv00083sas4wh40lk4","category_id":"cjc8oaieb000l3sas3y9ndgqh","_id":"cjc8oaiep00153sasqtkixeqr"},{"post_id":"cjc8oaief000r3saskrs25dvu","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaier00183sasl4ztyitw"},{"post_id":"cjc8oaiej000w3sasn1lokdkr","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaiev001d3sas3v4zi5q9"},{"post_id":"cjc8oaidz000a3sas8hp10e1y","category_id":"cjc8oaieb000l3sas3y9ndgqh","_id":"cjc8oaiew001g3sas7m0ma0l3"},{"post_id":"cjc8oaiem000z3sass189i4kg","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaif2001k3sasfsoeb6l2"},{"post_id":"cjc8oaieo00143sascdjhf5rk","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaif3001n3sas5a9kx0iy"},{"post_id":"cjc8oaie1000d3sash8y3ncm1","category_id":"cjc8oaieb000l3sas3y9ndgqh","_id":"cjc8oaif5001q3sasq1s3bc0u"},{"post_id":"cjc8oaieq00173sasfmtcsz8r","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaif6001s3sas38vh0s0o"},{"post_id":"cjc8oaiet001c3sasqag98bj5","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaif7001v3sasfxha7vzs"},{"post_id":"cjc8oaiec000o3sasox0rgx0l","category_id":"cjc8oaier001a3sasjgjcplo8","_id":"cjc8oaif8001x3saswhy3epfq"},{"post_id":"cjc8oaiev001f3sasvbb8zih0","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaif8001z3sasrlwobkwu"},{"post_id":"cjc8oaiex001j3saslwtp9xhr","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaif800213sas71yz74sh"},{"post_id":"cjc8oaif2001m3sasvwus3g4q","category_id":"cjc8oaidq00053sasgv8x4308","_id":"cjc8oaif900233sasvu2r6cf7"}],"PostTag":[{"post_id":"cjc8oaida00003sas1kvf2kvd","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaie1000c3sasx5n60y8g"},{"post_id":"cjc8oaie7000i3sasemads3e2","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaieb000n3sas3anqrfok"},{"post_id":"cjc8oaidg00023saszs7qpv82","tag_id":"cjc8oaidz00093saswwdjz3ir","_id":"cjc8oaiee000q3sasyruoosxr"},{"post_id":"cjc8oaidg00023saszs7qpv82","tag_id":"cjc8oaie5000g3sasehcx5ys0","_id":"cjc8oaiej000u3sas18m0nbub"},{"post_id":"cjc8oaie9000j3sasd8fe17d8","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaiel000y3sasac9rusdt"},{"post_id":"cjc8oaids00063sas2dedzcm0","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaien00113sasn00kir9e"},{"post_id":"cjc8oaiej000w3sasn1lokdkr","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaieq00163sasragl0lg0"},{"post_id":"cjc8oaidv00083sas4wh40lk4","tag_id":"cjc8oaiei000t3sasho51y7yq","_id":"cjc8oaier00193sasdhlz0ex1"},{"post_id":"cjc8oaiem000z3sass189i4kg","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaiev001e3sasjdb903q8"},{"post_id":"cjc8oaieo00143sascdjhf5rk","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaiex001h3sasitfhg61r"},{"post_id":"cjc8oaidz000a3sas8hp10e1y","tag_id":"cjc8oaiei000t3sasho51y7yq","_id":"cjc8oaif2001l3sasnmrhukwi"},{"post_id":"cjc8oaieq00173sasfmtcsz8r","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaif5001o3sass9hqionr"},{"post_id":"cjc8oaiet001c3sasqag98bj5","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaif5001r3sase3n0ba9s"},{"post_id":"cjc8oaie1000d3sash8y3ncm1","tag_id":"cjc8oaiei000t3sasho51y7yq","_id":"cjc8oaif6001t3sasl7do1645"},{"post_id":"cjc8oaiev001f3sasvbb8zih0","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaif7001w3sassbzbzp4s"},{"post_id":"cjc8oaiex001j3saslwtp9xhr","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaif8001y3sasnibnz3zu"},{"post_id":"cjc8oaie4000f3sasckzf13fa","tag_id":"cjc8oaie5000g3sasehcx5ys0","_id":"cjc8oaif800203sas7epxksi2"},{"post_id":"cjc8oaif2001m3sasvwus3g4q","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaif800223sasfnfrdt1a"},{"post_id":"cjc8oaiec000o3sasox0rgx0l","tag_id":"cjc8oaif5001p3sas0dlr5b3x","_id":"cjc8oaif900243sastz6podf9"},{"post_id":"cjc8oaief000r3saskrs25dvu","tag_id":"cjc8oaidl00043sas6bdogob9","_id":"cjc8oaif900253sasukut2ejs"},{"post_id":"cjc8oaief000r3saskrs25dvu","tag_id":"cjc8oaif7001u3sasvtllh61g","_id":"cjc8oaif900263sas52xy46ko"}],"Tag":[{"name":"Java","_id":"cjc8oaidl00043sas6bdogob9"},{"name":"博客之路","_id":"cjc8oaidz00093saswwdjz3ir"},{"name":"HEXO","_id":"cjc8oaie5000g3sasehcx5ys0"},{"name":"SQL","_id":"cjc8oaiei000t3sasho51y7yq"},{"name":"生活,感想","_id":"cjc8oaif5001p3sas0dlr5b3x"},{"name":"Exception","_id":"cjc8oaif7001u3sasvtllh61g"}]}}