{"id":24091,"date":"2024-11-21T11:53:02","date_gmt":"2024-11-21T03:53:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/24091\/"},"modified":"2024-11-21T11:53:02","modified_gmt":"2024-11-21T03:53:02","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8webman%e6%a1%86%e6%9e%b6%e5%ae%9e%e7%8e%b0%e4%ba%a7%e5%93%81%e5%8d%8f%e5%90%8c%e5%92%8c%e5%9b%a2%e9%98%9f%e5%8d%8f%e4%bd%9c%e5%8a%9f%e8%83%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/24091\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528Webman\u6846\u67b6\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\uff1f"},"content":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528webman\u6846\u67b6\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\uff1f<\/p>\n<p>Webman\u6846\u67b6\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684Web\u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u8bf8\u591a\u529f\u80fd\u548c\u5de5\u5177\uff0c\u65b9\u4fbf\u5f00\u53d1\u8005\u6784\u5efa\u9ad8\u6548\u3001\u5b89\u5168\u548c\u53ef\u6269\u5c55\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528Webman\u6846\u67b6\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728\u9879\u76ee\u4e2d\u5f15\u5165Webman\u6846\u67b6\u3002\u53ef\u4ee5\u5728\u9879\u76ee\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4f9d\u8d56\u9879\uff1a<\/p>\n<pre>&lt;dependency&gt;&lt;groupid&gt;org.webman&lt;\/groupid&gt;&lt;artifactid&gt;webman-core&lt;\/artifactid&gt;&lt;version&gt;1.0.0&lt;\/version&gt;&lt;\/dependency&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u63a7\u5236\u5668\u7c7b\u6765\u5904\u7406\u534f\u540c\u548c\u534f\u4f5c\u529f\u80fd\u7684\u8bf7\u6c42\u3002\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aCollaborationController\u7684\u7c7b\uff0c\u5e76\u4f7f\u7528@Controller\u6ce8\u89e3\u8fdb\u884c\u6807\u8bb0\u3002\u8be5\u7c7b\u5e94\u8be5\u7ee7\u627f\u81eaWebman\u7684\u57fa\u7840\u63a7\u5236\u5668\u7c7bAbstractController\u3002<\/p>\n<pre>@Controller\npublic class CollaborationController extends AbstractController {\n\n    \/\/ \u6dfb\u52a0\u534f\u540c\u529f\u80fd\u7684\u5904\u7406\u65b9\u6cd5\n    @RequestMapping(\"\/collaboration\")\n    public String collaboration(Model model) {\n        \/\/ \u5b9e\u73b0\u534f\u540c\u529f\u80fd\u7684\u903b\u8f91\n        return \"collaboration\";\n    }\n\n    \/\/ \u6dfb\u52a0\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u7684\u5904\u7406\u65b9\u6cd5\n    @RequestMapping(\"\/team-collaboration\")\n    public String teamCollaboration(Model model) {\n        \/\/ \u5b9e\u73b0\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u7684\u903b\u8f91\n        return \"team-collaboration\";\n    }\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528@RequestMapping\u6ce8\u89e3\u6765\u6307\u5b9aURL\u8def\u5f84\uff0c\u5e76\u8fd4\u56de\u76f8\u5e94\u7684\u89c6\u56fe\u540d\u79f0\u3002\u89c6\u56fe\u540d\u79f0\u5bf9\u5e94\u4e8eWeb\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6a21\u677f\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528Thymeleaf\u6216\u5176\u4ed6\u6a21\u677f\u5f15\u64ce\u8fdb\u884c\u6e32\u67d3\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6eWebman\u6846\u67b6\u7684\u8def\u7531\u5668\uff0c\u4ee5\u4fbf\u5c06\u8bf7\u6c42\u6620\u5c04\u5230\u76f8\u5e94\u7684\u63a7\u5236\u5668\u65b9\u6cd5\u3002\u53ef\u4ee5\u5728\u9879\u76ee\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre>@Configuration\npublic class WebmanConfig implements WebMvcConfigurer {\n\n    @Autowired\n    private CollaborationController collaborationController;\n\n    @Override\n    public void addViewControllers(ViewControllerRegistry registry) {\n        registry.addViewController(\"\/collaboration\").setViewName(\"collaboration\");\n        registry.addViewController(\"\/team-collaboration\").setViewName(\"team-collaboration\");\n    }\n\n    @Override\n    public void addInterceptors(InterceptorRegistry registry) {\n        registry.addInterceptor(new LoggingHandlerInterceptor());\n    }\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86addViewControllers\u65b9\u6cd5\u5c06URL\u8def\u5f84\u6620\u5c04\u5230\u89c6\u56fe\u540d\u79f0\uff0c\u6839\u636e\u9700\u8981\u53ef\u4ee5\u6dfb\u52a0\u66f4\u591a\u7684\u6620\u5c04\u914d\u7f6e\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u5bf9\u5e94\u7684\u6a21\u677f\u6587\u4ef6\uff0c\u7528\u4e8e\u6e32\u67d3\u9875\u9762\u3002\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3acollaboration.html\u7684\u6a21\u677f\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u4ea7\u54c1\u534f\u540c\u529f\u80fd\u7684\u76f8\u5173\u5185\u5bb9\u3002<\/p>\n<pre>\n\n\n    &lt;meta charset=\"UTF-8\"&gt;&lt;title&gt;\u4ea7\u54c1\u534f\u540c&lt;\/title&gt;&lt;h1&gt;\u4ea7\u54c1\u534f\u540c\u529f\u80fd&lt;\/h1&gt;\n    &lt;!-- \u6dfb\u52a0\u4ea7\u54c1\u534f\u540c\u529f\u80fd\u7684\u9875\u9762\u5185\u5bb9 --&gt;\n\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7c7b\u4f3c\u5730\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3ateam-collaboration.html\u7684\u6a21\u677f\u6587\u4ef6\uff0c\u7528\u4e8e\u6e32\u67d3\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u7684\u9875\u9762\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528Webman\u6846\u67b6\u6765\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u4e86\u3002\u5f53\u8bbf\u95ee\u5bf9\u5e94\u7684URL\u65f6\uff0cWebman\u6846\u67b6\u5c06\u4f1a\u5c06\u8bf7\u6c42\u6620\u5c04\u5230\u76f8\u5e94\u7684\u63a7\u5236\u5668\u65b9\u6cd5\uff0c\u5e76\u6e32\u67d3\u5bf9\u5e94\u7684\u6a21\u677f\u6587\u4ef6\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u4f7f\u7528Webman\u6846\u67b6\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u975e\u5e38\u7b80\u5355\u3002\u901a\u8fc7\u5408\u7406\u7684\u914d\u7f6e\u548c\u7f16\u5199\u63a7\u5236\u5668\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u6784\u5efa\u51fa\u9ad8\u6548\u3001\u5b89\u5168\u548c\u53ef\u6269\u5c55\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528Webman\u6846\u67b6\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528webman\u6846\u67b6\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\uff1f Webman\u6846\u67b6\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684Web\u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u8bf8\u591a\u529f\u80fd\u548c\u5de5\u5177\uff0c\u65b9\u4fbf\u5f00\u53d1\u8005\u6784\u5efa\u9ad8\u6548\u3001\u5b89\u5168\u548c\u53ef\u6269\u5c55\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528Webman\u6846\u67b6\u5b9e\u73b0\u4ea7\u54c1\u534f\u540c\u548c\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u3002 \u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728\u9879\u76ee\u4e2d\u5f15\u5165Webman\u6846\u67b6\u3002\u53ef\u4ee5\u5728\u9879\u76ee\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4f9d\u8d56\u9879\uff1a &lt;dependency&gt;&lt;groupid&gt;org.webman&lt;\/groupid&gt;&lt;artifactid&gt;webman-core&lt;\/artifactid&gt;&lt;version&gt;1.0.0&lt;\/version&gt;&lt;\/dependency&gt; \u767b\u5f55\u540e\u590d\u5236 \u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u63a7\u5236\u5668\u7c7b\u6765\u5904\u7406\u534f\u540c\u548c\u534f\u4f5c\u529f\u80fd\u7684\u8bf7\u6c42\u3002\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aCollaborationController\u7684\u7c7b\uff0c\u5e76\u4f7f\u7528@Controller\u6ce8\u89e3\u8fdb\u884c\u6807\u8bb0\u3002\u8be5\u7c7b\u5e94\u8be5\u7ee7\u627f\u81eaWebman\u7684\u57fa\u7840\u63a7\u5236\u5668\u7c7bAbstractController\u3002 @Controller public class CollaborationController extends AbstractController { \/\/ \u6dfb\u52a0\u534f\u540c\u529f\u80fd\u7684\u5904\u7406\u65b9\u6cd5 @RequestMapping(&#8220;\/collaboration&#8221;) public String collaboration(Model model) { \/\/ \u5b9e\u73b0\u534f\u540c\u529f\u80fd\u7684\u903b\u8f91 return &#8220;collaboration&#8221;; } \/\/ \u6dfb\u52a0\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u7684\u5904\u7406\u65b9\u6cd5 @RequestMapping(&#8220;\/team-collaboration&#8221;) public String teamCollaboration(Model model) { \/\/ \u5b9e\u73b0\u56e2\u961f\u534f\u4f5c\u529f\u80fd\u7684\u903b\u8f91 return &#8220;team-collaboration&#8221;; } } \u767b\u5f55\u540e\u590d\u5236 \u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528@RequestMapping\u6ce8\u89e3\u6765\u6307\u5b9aURL\u8def\u5f84\uff0c\u5e76\u8fd4\u56de\u76f8\u5e94\u7684\u89c6\u56fe\u540d\u79f0\u3002\u89c6\u56fe\u540d\u79f0\u5bf9\u5e94\u4e8eWeb\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6a21\u677f\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528Thymeleaf\u6216\u5176\u4ed6\u6a21\u677f\u5f15\u64ce\u8fdb\u884c\u6e32\u67d3\u3002 \u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6eWebman\u6846\u67b6\u7684\u8def\u7531\u5668\uff0c\u4ee5\u4fbf\u5c06\u8bf7\u6c42\u6620\u5c04\u5230\u76f8\u5e94\u7684\u63a7\u5236\u5668\u65b9\u6cd5\u3002\u53ef\u4ee5\u5728\u9879\u76ee\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a @Configuration public class WebmanConfig implements WebMvcConfigurer { @Autowired private CollaborationController collaborationController; @Override [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-24091","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/24091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=24091"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/24091\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=24091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=24091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=24091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}