beego实现web api接口
2020-12-13 16:05
标签:style blog http io color ar java for sp 1)程序代码: 2)视图代码: ---童飞 beego实现web api接口 标签:style blog http io color ar java for sp 原文地址:http://www.cnblogs.com/yunkeji/p/4079335.html/**
* 类似beego版物联网首页产品数据的调用
*/import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/httplib"
)
type MainController struct {
beego.Controller
}
func (this *MainController) Get() {
str, _ := httplib.Get("http://shop.iotywl.com/tools/cms.ashx?cmdParam=Select_Product_List").String()
this.Data["JsonDatas"] = str
this.TplNames = "index.html"
}DOCTYPE html>
html>
head>
title>Beegotitle>
meta http-equiv="Content-Type" content="text/html; charset=utf-8">
script type="text/javascript" src="/static/js/jquery-1.9.1.min.js">script>
head>
body>
ul id="html_data">ul>
body>
script type="text/javascript">
var jsonDatas= "{{.JsonDatas}}";
$(function(){
var web_url = "http://shop.iotywl.com";
var image_url = "http://images.iotywl.com"
var list=eval(jsonDatas);
var strTemp = "";
for (var i = 0; i list.length; i++) {
strTemp += "" + image_url + list[i].SmallImage + "\" />" + list[i].Title + "
上一篇:Java 抽象类
下一篇:C#中float的取值范围和精度