1.app/controllers/app.go Controller
Package Controllersimport"Github.com/revel/revel"type Appstruct { *Revel. Controller}func (c App) Index () Revel. Result {str:="pass a variable to the template to see" returnC.render (str)}func (c App) Hello (Namestring) Revel. Result {c.validation.required (Name). Message ("name must be filled") ifc.validation.haserrors () {c.validation.keep () c.flashparams ( )returnc.redirect (App.index)}returnC.render (Name)}
2.app/views/app/index.html template file (the corresponding controller is the Index method of the App.go file)
{{Set."title" "Home"}}{{template"header.html" .}}class="Hero-unit"style="Background-color: #A9F16C"> <divclass="Container"> <divclass="Row"> <divclass="Hero-text"> {{range. Errors}}<p style="Color: #c00">{{. Message}}</p>{{end}}<form action="/app/hello"Method="GET"> <input type="text"Name="Name"Value="{. Flash. Name}}"/> <input type="Submit"Value="Submit"/></form>{{Template"footer.html".}}
app/views/app/hello.html template file (the corresponding controller is the Hello method for the App.go file)
{{set"title""Home"" header.html" .}} "/"> Back </a>" footer.html" .}}
Go Revel a preliminary study