{"rsdb":{"rid":"242887","subhead":"","postdate":"0","aid":"167224","fid":"78","uid":"1","topic":"1","content":"
\n

\u6a21\u677f\u4f7f\u7528<\/p> \n

\u9875\u9762\u5e03\u5c40<\/p> \n

1>     \u4e00\u4e2ahtml\u9875\u9762\u7531:head\u90e8\u5206,body\u90e8\u5206,\u5185\u90e8css,\u5185\u90e8js,\u5916\u8054css,\u5916\u8054\u7684js\u8fd9\u51e0\u90e8\u5206\u7ec4\u6210\u3002\u56e0\u6b64\uff0c\u4e00\u4e2a\u5e03\u5c40\u6587\u4ef6\u4e5f\u5c31\u9700\u8981\u9488\u5bf9\u8fd9\u4e9b\u8fdb\u884c\u62c6\u5206\u3002<\/p> \n

 \"\"<\/p> \n

 <\/p> \n

2>     \u65b0\u5efa\u4e00\u4e2alayout.go\u7684\u63a7\u5236\u5668\u3002\u7f16\u5199\u4e00\u4e2a\u5f15\u7528\u5e03\u5c40\u6587\u4ef6\u7684\u5b9e\u4f8b\u3002\u5177\u4f53\u4ee3\u7801\u5982\u4e0b:<\/p> \n

   <\/p> \n

\n
package controllers\n\nimport (\n\t"fmt"\n\t"log"\n\t"html\/template"\n\t"github.com\/gin-gonic\/gin"\n\t"net\/http"\n)\n\n\/**\u5185\u5bb9\u9875\u9762**\/\nfunc Contenthtml(c *gin.Context){\n\n    \/\/\u6a21\u677f\u6587\u4ef6\u7684\u62fc\u63a5\n\tt, err := template.ParseFiles("views\/layout.html", "views\/head.tpl", \n\t\t"views\/content.html","views\/sidebar.tpl","views\/scripts.tpl")\n\t\/\/\u5907\u6ce8:\u53c2\u65701\u300b\u6a21\u677f\u9875\u9762\uff1b\u53c2\u65702\u300bcss\u90e8\u5206\uff1b\u53c2\u65703\u300b\u5185\u5bb9\u90e8\u5206\uff1b\n\t\/\/\u53c2\u65704\u300b\u5e95\u90e8\u7248\u6743\u4fe1\u606f\u90e8\u5206;\u53c2\u65705\u300b\u9875\u9762\u4e2d\u4f7f\u7528\u5230\u7684js\u90e8\u5206\n    if err != nil {\n        log.Fatal(err)\n    }\n\tfmt.Println(t)\n\t\/\/\u6e32\u67d3html\u6587\u4ef6\n\tc.HTML(http.StatusOK,"layout.html", gin.H{\n\t\t"title": "\u5e03\u5c40\u9875\u9762",\n\t})\n}\n<\/pre> \n <\/div> \n 

\u3000\u3000<\/p> \n

3>     \u65b0\u5efa\u5e03\u5c40\u9875\u9762\uff0c\u5177\u4f53\u7684\u5982\u4e0b\u56fe\u6240\u793a<\/p> \n

 \"\"<\/p> \n

 <\/p> \n

4>     \u5728\u8def\u7531\u5668\u4e2d\u6dfb\u52a0\u4ee3\u7801\uff0c\u7f16\u8bd1\u8fd0\u884c\u9879\u76ee\uff0c\u4fee\u8ba2\u9519\u8bef\uff0c\u67e5\u770b\u8fd0\u884c\u7684\u6548\u679c<\/p> \n

   <\/p> \n

\n
package routers\n\nimport (\n  "github.com\/gin-gonic\/gin"\n  . "GinLearn\/GinLearn\/apis" \/\/api\u90e8\u5206\n  . "GinLearn\/GinLearn\/controllers" \/\/constroller\u90e8\u5206\n )\n \nfunc InitRouter() *gin.Engine{\n  router := gin.Default()\n  \/\/Hello World\n  router.GET("\/", IndexApi)\n  \/\/\u6e32\u67d3html\u9875\u9762\n  router.LoadHTMLGlob("views\/*")\n\n  router.GET("\/home\/index", ShowHtmlPage)\n  \/\/\u5217\u8868\u9875\u9762\n  router.GET("\/home\/list", ListHtml)\n  router.POST("\/home\/PageData", GetDataList)\n  router.POST("\/home\/PageNextData", PageNextData)\n\n  \/\/\u65b0\u589e\u9875\u9762\n  router.GET("\/home\/add", AddHtml)\n  router.POST("\/home\/saveadd", AddPersonApi)\n  \n   \/\/\u7f16\u8f91\u9875\u9762\n   router.GET("\/home\/edit", EditHtml)\n   router.POST("\/home\/saveedit", EditPersonApi)\n\n    \/\/\u5220\u9664\n    router.POST("\/home\/delete", DeletePersonApi)\n\n    \/\/Bootstrap\u5e03\u5c40\u9875\u9762\n    router.GET("\/home\/bootstrap", Bootstraphtml)\n\n    \/\/\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d \n    router.GET("\/home\/fileopt", Fileopthtml)\n    router.POST("\/home\/fileuplaod", Fileupload)\n    router.GET("\/home\/filedown", Filedown)\n\n    \/\/\u6587\u4ef6\u7684\u521b\u5efa\u5220\u9664\u548c\u8bfb\u5199\n    router.GET("\/home\/filerw", Filerwhtml)\n    router.POST("\/home\/addfile", FilerCreate)\/\/\u521b\u5efa\u6587\u4ef6\n    router.POST("\/home\/writefile", FilerWrite)\/\/\u5199\u5165\u6587\u4ef6\n    router.POST("\/home\/readfile", FilerRead)\/\/\u8bfb\u53d6\u6587\u4ef6\n    router.POST("\/home\/deletefile", FilerDelete)\/\/\u5220\u9664\u6587\u4ef6\n    \n    \/\/api\u8c03\u7528\u7684\u90e8\u5206\n    router.GET("\/home\/api", GetApiHtml) \n    router.GET("\/api\/jsondata", GetJsonData) \n    router.GET("\/api\/xmldata", GetXmlData) \n    router.GET("\/api\/yamldata", GetYamlData) \n    router.GET("\/api\/paramsdata", GetParamsJsonData) \n\n    \/\/\u5e03\u5c40\u9875\u9762\n    router.GET("\/home\/content", Contenthtml)\n    \n    return router\n }\n \n<\/pre> \n <\/div> \n 

\u3000\u3000<\/p> \n

5>     \u8fd0\u884c\u6548\u679c\u5982\u4e0b:<\/p> \n

 \"\"<\/p> \n

 <\/p> \n

6>     Layout.html\u5177\u4f53\u7684\u4ee3\u7801\u5982\u4e0b:<\/p> \n

 <\/p> \n

\n
<!DOCTYPE html>\n<html>\n<head>\n    <title>{{ .title }}<\/title>\n    <meta name="viewport" content="width=device-width, initial-scale=1.0">\n    <meta http-equiv="Content-Type" content="text\/html; charset=utf-8">\n    <l","orderid":"0","title":"Gin-Go\u5b66\u4e60\u7b14\u8bb0\u4e03\uff1aGin-Web\u6846\u67b6 \u5e03\u5c40\u9875\u9762(\u4e00)","smalltitle":"","mid":"0","fname":"GO","special_id":"0","bak_id":"0","info":"0","hits":"2203","pages":"2","comments":"0","posttime":"2017-12-23 06:06:44","list":"1513980404","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"http:\/\/images2017.cnblogs.com\/blog\/1290422\/201712\/1290422-20171221161300646-231918569.png","ispic":"1","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Gin-Go<\/A> \u5b66\u4e60<\/A> \u7b14\u8bb0<\/A> Gin-Web<\/A> \u6846\u67b6<\/A> \u5e03\u5c40<\/A> \u9875\u9762<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"113.110.148.159","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Gin-Go\u5b66\u4e60\u7b14\u8bb0\u4e03\uff1aGin-Web\u6846\u67b6 \u5e03\u5c40\u9875\u9762","lastview":"1713604374","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}