beego4---web项目结构

app.conf
appname = blog1
httpport =
runmode = dev controllersmy
package controllersmy //跟外面的包名一致 import (
"github.com/astaxie/beego"
) type MainController struct {
beego.Controller //"github.com/astaxie/beego"包里面的Controller
} func (c *MainController) Get() {
//模版
c.Data["Website"] = "beego.me22222222222"
c.Data["Email"] = "astaxie@gmail.com"
c.TplName = "index.tpl"
c.Data["Truecondition"] = true
c.Data["falsecondotion"] = false type u struct {
Name string
Age int
Sex string
} user := &u{
Name: "name",
Age: ,
Sex: "难",
}
c.Data["user"] = user nums := []int{, , , , , , , , }
c.Data["nums"] = nums //模版变量
c.Data["tempvalue"] = "tempsssvalue" //如果html是安全的,可以直接显示html内容
c.Data["html"] = "<div>ssss<div>" c.Data["pipe"] = "<div>pipe<div>"
} router.go
package routers import (
"blog1/controllersmy"
"github.com/astaxie/beego"
) func init() {
beego.Router("/", &controllersmy.MainController{}) //"blog1/controllersmy"里面的 &controllersmy
} 页面
<!DOCTYPE html> <html>
<head>
<title>Beego</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="" type="image/x-icon" /> <style type="text/css">
*,body {
margin: 0px;
padding: 0px;
} body {
margin: 0px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 20px;
background-color: #fff;
} header,
footer {
width: 960px;
margin-left: auto;
margin-right: auto;
} .logo {
background-image: url('');
background-repeat: no-repeat;
-webkit-background-size: 100px 100px;
background-size: 100px 100px;
background-position: center center;
text-align: center;
font-size: 42px;
padding: 250px 70px;
font-weight: normal;
text-shadow: 0px 1px 2px #ddd;
} header {
padding: 100px ;
} footer {
line-height: 1.8;
text-align: center;
padding: 50px ;
color: #;
} .description {
text-align: center;
font-size: 16px;
} a {
color: #;
text-decoration: none;
} .backdrop {
position: absolute;
width: %;
height: %;
box-shadow: inset 0px 0px 100px #ddd;
z-index: -;
top: 0px;
left: 0px;
}
</style>
</head> <body>
<header>
</header> <div class="">
<!-- 通过.语法获取c *MainController,c.Data["user"] = user里面的数据 -->
{{if .Truecondition}}
true Truecondition
{{end}}
</div> <div class="">
{{.user.Name}};
{{.user.Age}};
{{.user.Sex}}
</div> <div class="">
<!-- 前缀相同使用with进行省略写法 -->
{{with .user}}
{{.Name}};
{{.Age}};
{{.Sex}};
{{end}}
</div> <div class="">
{{.nums}}
<!-- 循环打印数组 -->
{{range .nums}}
{{.}}
{{end}}
</div> <div class="">
<!-- 模版变量 ,$a就是一个模版变量,并且赋值了,-->
{{$a := .tempvalue}}
{{$a}}
</div>
{{.html}}
{{str2html .html}}<!-- string转成了html -->
<div class="">
{{.pipe | htmlquote}}
</div>
<div class="">
{{template "test"}}<!-- 使用模版 -->
</div>
<footer>
</footer> <script src="/static/js/reload.min.js"></script>
</body>
</html> {{define "test"}}<!-- 模版定义 -->
<div>
this is temlpe
<div>
{{end}} main.go
package main import (
_ "blog1/routers"
"github.com/astaxie/beego"
) func main() {
beego.Run()
}
beego4---web项目结构的更多相关文章
- Java Web项目结构
Java Web项目结构(一般) 1.Java src 2.JRE System Library 3.Java EE 6 Libraries 4.Web App Libraries 5.WebRoot ...
- 使用maven构建基本的web项目结构
由于当前公司在组织进行项目基本结构的整理,将以前通过eclipse/ ant 方式构建的项目向maven上迁移,于是便进行maven项目方面的调研. 对于maven项目,基本的结构已经在标准文件中: ...
- VS2015 ASP.NET5 Web项目结构浅析
前言 本文个人同步博客地址http://aehyok.com/Blog/Detail/76.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本 ...
- node web项目结构
- 主要介绍JavaEE中Maven Web 项目的结构及其它几个小问题
先说下本篇随笔的目录. 1.介绍windows中环境变量Path与ClassPath的区别. 2.可能导致命令行运行javac编译成功,但 java命令 + 所要执行的类的类名 无效的原因. 3.介绍 ...
- Maven-搭建maven web项目
点击Eclipse菜单File->New->Other->Maven->Maven Project 在选择maven-archetype的界面进行如下操作:(其他选项基本与创建 ...
- Java Web学习系列——创建基于Maven的Web项目
创建Maven Web项目 在MyEclipse for Spring中新建Maven项目 选择项目类型,在Artifact Id中选择maven-archetype-webapp 输入Group I ...
- VS2015 ASP.NET5 Web项目
VS2015 ASP.NET5 Web项目结构浅析 前言 本文个人同步博客地址http://aehyok.com/Blog/Detail/76.html 在安装好VS2015之后,一直想看看新版本 ...
- WEB项目(B/S系统)打包安装(总结篇)
原文:WEB项目(B/S系统)打包安装(总结篇) 打包安装程序的制作选择性还很多的,有installshield,wise installer,inno setup这几个做打包安装项目都是很强大的,要 ...
- 使用 IDEA 创建 Maven Web 项目 (二)- 搭建 WEB 项目框架
转为 Java Web 项目 将上一节中创建的 Maven 项目调整为 WEB 项目结构,步骤如下: 在 main 目录下,添加 webapp 目录. 在 webapp 目录下,添加 WEB-INF ...
随机推荐
- 精准判断是360、IE和其他浏览器
function myexplorer(){ var explorer = window.navigator.userAgent; if (!!window.ActiveXObject || &quo ...
- jquery.data.resource.js
/*! * jQeury Data Pkugin * version: 1.0.0-2016.03.03 * Requires jQuery v1.10.2 or later * Copyright ...
- nodejs初探
var http= require('http');var server= http.createServer(function(req,res){ res.writeHead(200,{" ...
- 装饰器(python)
一,装饰器定义:本质就是函数,功能是为其他函数添加新功能原则:1.不修改被装饰函数的源代码(开放封闭原则)2.为被装饰函数添加新功能后,不修改被修饰函数的调用方式3.装饰器=高阶函数+函数嵌套+闭包高 ...
- 零基础入门学习Python(10)--列表:一个打了激素的数组
前言 有时候我们需要把一些东西暂时保存起来,因为他们有着一些直接或间接的联系,我们需要把它们放在某个组或者集合中,未来可能用得上. 很多接触过编程的朋友都知道,都接触过数组这个概念,那么数组这个概念事 ...
- Linux htop工具使用详解【转】
原文地址: http://www.cnphp6.com/archives/65078 一.Htop的使用简介 大家可能对top监控软件比较熟悉,今天我为大家介绍另外一个监控软件Htop,姑且称之为to ...
- assert.doesNotThrow()
assert.doesNotThrow(block[, error][, message]) 断言 block 函数不会抛出错误.查阅 assert.throws() 了解更多详情. 当调用 asse ...
- c++基础_杨辉三角形
#include <iostream> using namespace std; int main(){ int n; cin>>n; ][]; ;i<n;i++){ a ...
- vue中的表单验证
http://www.cnblogs.com/luoxuemei/p/9295506.html /*是否合法IP地址*/ export function validateIP(rule, value, ...
- maven项目运行tomcat7-maven-plugin:run时出现Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.util.Scanner(xjl456852原创)
使用tomcat7-maven-plugin插件运行web项目时, 出现下面错误: [WARNING] Error injecting: org.sonatype.plexus.build.incre ...