新聞中心
自定義Controller 是一個直接或間接嵌入了 *Revel.Controller 的struct。

十余年的陽信網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整陽信建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)從事“陽信網(wǎng)站設(shè)計”,“陽信網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。
典型用法:
type AppController struct {
*revel.Controller
}*revel.Controller 在你自定義的struct中必須是第一個嵌入的類型
revel.Controller 用于請求的上下文,包含了請求與響應(yīng)數(shù)據(jù),請到 the godoc 查看完整內(nèi)容, 下面是一個定義 (以及輔助類型的定義):
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和表單中的參數(shù)(包擴 multipart).
Args map[string]interface{} // 每個請求的暫存空間
RenderArgs map[string]interface{} // 傳遞給模板的參數(shù)
Validation *Validation // 數(shù)據(jù)驗證幫助器
}
// 統(tǒng)一的請求參數(shù)包裝
// 包括:
// - 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實例化一個控制器,設(shè)置所有revel.Controller嵌入的屬性, 因此, Revel 不在請求之間共享實例,對于每個請求的處理,控制器都是獨立的。
本文標(biāo)題:創(chuàng)新互聯(lián)Revel教程:Revel 控制器概要
網(wǎng)頁地址:http://www.dlmjj.cn/article/coheodd.html


咨詢
建站咨詢
