新聞中心
這里有您想知道的互聯網營銷解決方案
創(chuàng)新互聯Revel教程:Revel 控制器概要
自定義Controller 是一個直接或間接嵌入了 *Revel.Controller 的struct。

十余年的陽信網站建設經驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。全網營銷推廣的優(yōu)勢是能夠根據用戶設備顯示端的尺寸不同,自動調整陽信建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯從事“陽信網站設計”,“陽信網站推廣”以來,每個客戶項目都認真落實執(zhí)行。
典型用法:
type AppController struct {
*revel.Controller
}*revel.Controller 在你自定義的struct中必須是第一個嵌入的類型
revel.Controller 用于請求的上下文,包含了請求與響應數據,請到 the godoc 查看完整內容, 下面是一個定義 (以及輔助類型的定義):
type Controller struct {
Name string // 控制器名稱, 比如: "Application"
Type *ControllerType // 控制器類型描述
MethodType *MethodType // 控制器方法描述
AppController interface{} // 控制器實例
Request *Request
Response *Response
Result Result
Flash Flash // 用戶 cookie, 在請求之后清空
Session Session // Session, 保存在cookie中,簽名。
Params *Params // URL和表單中的參數(包擴 multipart).
Args map[string]interface{} // 每個請求的暫存空間
RenderArgs map[string]interface{} // 傳遞給模板的參數
Validation *Validation // 數據驗證幫助器
}
// 統(tǒng)一的請求參數包裝
// 包括:
// - URL 查詢字符串
// - Form 表單字段
// - File 文件上傳
type Params struct {
url.Values
Files map[string][]*multipart.FileHeader
}
type Request struct {
*http.Request
ContentType string
}
type Response struct {
Status int
ContentType string
Headers http.Header
Cookies []*http.Cookie
Out http.ResponseWriter
}作為HTTP請求處理的一部分,Revel實例化一個控制器,設置所有revel.Controller嵌入的屬性, 因此, Revel 不在請求之間共享實例,對于每個請求的處理,控制器都是獨立的。
網頁名稱:創(chuàng)新互聯Revel教程:Revel 控制器概要
網頁鏈接:http://m.5511xx.com/article/coheodd.html


咨詢
建站咨詢
