html 代码:

@using GreenWay.Models;
@{
Model.Scripts = new string[] {
"~/Scripts/paginationViewModel.js",
"~/Views/Finance/Finance.cshtml.js" };
}
<style type="text/css" >
table th{
text-align:center;
}
</style>
@{
ViewBag.UserID = (Session["User"] as User).UserID;
}
<div class="page-content" style="padding-top: 0;">
<!-- BEGIN PAGE CONTENT-->
<div class="row">
<div class="col-md-12" style="margin-top:-10px">
<!-- BEGIN EXAMPLE TABLE PORTLET-->
<div class="portlet box blue-hoki" style="background-color: white">
<div class="portlet-title">
<div class="caption" style="font-weight:bold;margin:10px;">
融资管理
</div>
<div class="tools"></div>
</div>
<ul class="nav nav-tabs nav-justified" style="background-color: transparent">
<li data-bind="css:{'active':selectTab()==1}"><a data-bind="click:function(){changes(1)}">融资</a></li>
<li data-bind="css:{'active':selectTab()==2}"><a data-bind="click:function(){changes(2)}">保险</a></li>
</ul>
<div class="portlet-body" data-bind="visible:selectTab()==1">
<a href="javascript:void(0)" class="label label-info" style="margin:10px;" data-toggle="modal" data-target="#dvFinance" data-bind="click:function(){addFinance()}">添加</a>
<table class="table table-striped table-bordered table-hover" id="tblFinance" style="margin:10px; text-align: center;">
<thead>
<tr style="background-color:#00adef">
<th>
序号
</th>
<th>
融资名称
</th>
<th>
融资金额
</th>
<th>
贷款利率
</th>
<th>
手续费
</th>
<th>
期数
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody data-bind="visible: FinanceList().length > 0,foreach: FinanceList">
<tr>
<td data-bind="text:$index()+1"></td>
<td data-bind='text:FinanceName'></td>
<td data-bind='attr:{aid:ID},text:LoanCount'> </td>
<td data-bind="text:(Rate*100).toFixed(2)+'%'"></td>
<td data-bind='text:Fee'> </td>
<td data-bind='text:Period'> </td>
<td>
<a class="label label-info" data-toggle="modal" data-target="#dvFinance" data-bind="click:$parent.editFinance">编辑</a>
<a class="label label-info" data-bind="click:$parent.removeFinance">删除</a>
</td>
</tr>
</tbody>
</table> </div> <div class="portlet-body" data-bind="visible:selectTab()==2">
<a href="javascript:void(0)" class="label label-info" style="margin:10px;" data-toggle="modal" data-target="#dvInsuranceType" data-bind="click:addInsuranceType">添加</a>
<table class="table table-striped table-bordered table-hover" id="tbInsuranceType" style="margin:10px; text-align: center;">
<thead>
<tr style="background-color:#00adef">
<th>
序号
</th>
<th>
保险名称
</th>
<th>
保险金额
</th>
<th>
保险描述
</th>
<th>
是否强制
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody data-bind="visible: InsuranceTypeList().length > 0,foreach: InsuranceTypeList">
<tr>
<td data-bind="text:$index()+1"></td>
<td data-bind='attr:{aid:ID},text:InsuranceName'> </td>
<td data-bind='text:InsuranceMoney'> </td>
<td data-bind='text:InsuranceDesc'> </td>
<td data-bind='text:$parent.convertIsForce(IsForce)'> </td> <td>
<a class="label label-info" data-toggle="modal" data-target="#dvInsuranceType" data-bind="click:$parent.editInsuranceType">编辑</a>
<a class="label label-info" data-bind="click:$parent.removeInsuranceType">删除</a>
</td>
</tr>
</tbody>
</table> </div>
<div class="row datatables_paginate paging_full_numbers" style="text-align:center;" data-bind="visible: pages().length > 0">
<div class="small-12 columns" data-bind="template: 'PaginationTemplate'"></div>
</div>
</div> <!-- END EXAMPLE TABLE PORTLET-->
</div>
</div> <div class="modal fade bs-example-modal-lg" tabindex="-1" id="dvFinance" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" style="margin-top:10%">
<div class="modal-content" style="width:860px">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title" style="margin-left:4%;color:#00adef">
<i class="icon-docs" style="font-size: 24px;"></i>
<span data-bind="if:selectFinanceItem().ID==null">新建</span><span data-bind="if:selectFinanceItem().ID!=null">编辑</span>
</h4>
</div>
<div class="modal-body" style="border-top: 1px solid #EFEFEF; width: 90%;margin-left:5%">
<form id="formFinance" name="formFinance" class="form-horizontal">
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2">融资名称:</label>
<div class="col-md-10">
<input class="form-control required" type="text" data-bind="value:selectFinanceItem().FinanceName" name="fFinanceName" />
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2">融资金额:</label>
<div class="col-md-10">
<input class="form-control required" type="number" min="" data-bind="value:selectFinanceItem().LoanCount" name="fLoanCount" />
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2">贷款利率:</label>
<div class="col-md-10">
<input class="form-control required" type="number" min="" data-bind="value:selectFinanceItem().Rate" name="fRate" />
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2">手续费:</label>
<div class="col-md-10">
<input class="form-control required" type="number" min="" data-bind="value:selectFinanceItem().Fee" name="fFee" />
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2">期数:</label>
<div class="col-md-10">
<input class="form-control required" type="number" min="" data-bind="value:selectFinanceItem().Period" name="fPeriod" />
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button style="width: 42%;" type="button" class="btn blue" data-bind="click:function(){saveFinance();}">
确定
</button>
<button style="width: 42%;margin-right:8%" type="button" class="btn blue" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
<div class="modal fade bs-example-modal-lg" tabindex="-1" id="dvInsuranceType" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" style="margin-top:10%">
<div class="modal-content" style="width:1000px">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title" style="margin-left:4%;color:#00adef">
<i class="icon-docs" style="font-size: 24px;"></i>
<span data-bind="if:selectInsuranceTypeItem().ID==null">新建</span><span data-bind="if:selectInsuranceTypeItem().ID!=null">编辑</span>
</h4>
</div>
<div class="modal-body" style="border-top: 1px solid #EFEFEF; width: 90%;margin-left:5%">
<form id="formInsuranceType" name="formInsuranceType" class="form-horizontal">
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2"> 保险名称:</label>
<div class="col-md-10">
<input class="form-control required" type="text" maxlength="" data-bind="value:selectInsuranceTypeItem().InsuranceName" name="fInsuranceName" />
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2"> 保险金额:</label>
<div class="col-md-10">
<input class="form-control required" type="number" min="" data-bind="value:selectInsuranceTypeItem().InsuranceMoney" name="fInsuranceMoney"/>
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2"> 是否强制:</label>
<div class="col-md-10">
<input type="checkbox" data-bind="checked:selectInsuranceTypeItem().IsForce" name="fIsForce" />
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label col-md-2"> 保险描述:</label>
<div class="col-md-10">
<textarea class="form-control required" rows="" cols="" data-bind="value:selectInsuranceTypeItem().InsuranceDesc" name="fInsuranceDesc"></textarea>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button style="width: 42%;" type="button" class="btn blue" data-bind="click:function(){saveInsuranceType();}">
确定
</button>
<button style="width: 42%;margin-right:8%" type="button" class="btn blue" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
<!-- END PAGE CONTENT-->
<input id="hid_UserID" type="hidden" />
</div> <script type="text/html" id="PaginationTemplate">
<ul class="pagination" data-bind="visible: pages().length > 0">
<li><a data-bind="click: goToFirst"><<</a></li>
<li><a data-bind="click: goToPrev"><</a></li>
<!--ko if:showStartPagerDot-->
<li><a data-bind="click:StartPageDot">...</a></li>
<!--/ko-->
<!--ko foreach:pages-->
<li data-bind="css: { 'active': $data == $parent.currentPage() }">
<a data-bind="text: $data, click: $parent.goToPage.bind($data, $data)"></a>
</li>
<!--/ko-->
<!--ko if:showEndPagerDot-->
<li><a data-bind="click:EndPageDot">...</a></li>
<!--/ko-->
<li><a data-bind="click: goToNext">></a></li>
<li><a data-bind="click: goToLast">>></a></li>
</ul>
</script> <script type="text/javascript">
$("#hid_UserID").val("@ViewBag.UserID");
</script>

js代码:

$(function(){
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + , //月份
"d+": this.getDate(), //日
"h+": this.getHours() % == ? : this.getHours() % , //小时
"H+": this.getHours(),
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + ) / ), //季度
"f": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$, (this.getFullYear() + "").substr( - RegExp.$.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$, (RegExp.$.length == ) ? (o[k]) : (("" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
function GetNow() {
return new Date().Format("yyyy-MM-dd HH:mm:ss");
} var userid = $("#hid_UserID").val();
var Finance = function(){
this.ID = null;
this.FinanceName = "";
this.LoanCount=;
this.Rate=;
this.Fee=;
this.Period=;
this.IsDelete=;
}
var InsuranceType =function() {
this.ID=null;
this.InsuranceName="";
this.InsuranceDesc="";
this.IsForce=false;
this.InsuranceMoney=;
this.IsDelete=;
}
var financeFlag = false, insuranceTypeFlag = false; var isT = false;
var model = function () {
var self = this;
self.selectTab = ko.observable(),
self.FinanceList = ko.observableArray([]);
self.InsuranceTypeList = ko.observableArray([]);
self.selectFinanceItem = ko.observable(new Finance());
self.selectInsuranceTypeItem = ko.observable(new InsuranceType());
//头部tab切换
self.changes = function (val) {
self.selectTab(val);
self.goToPage();
}; //Finance
{
self.addFinance = function (o) {
self.selectFinanceItem(new Finance());
$("#formFinance").valid();
}
self.removeFinance = function (o) {
Confirm('你确定要删除该记录吗?').on(function () {
o.IsDelete = ;
o.UpdateTime = GetNow();
$.ajax({
url: "/api/CommonApi?API=UpdateFinancing",
type: "put",
data: { ApiParamObj: JSON.stringify(o) },
dataType: "json",
success: function (data) {
console.dir(data);
if (data.Success) {
Alert("删除成功").on(function () {
self.goToPage();
})
}
}
});
});
}
self.editFinance = function (o) {
$.ajax({
url: "/api/CommonApi?API=GetFinancingByID",
type: "get",
data: { ID: o.ID },
dataType: "json",
success: function (data) {
console.dir(data);
data = data.ApiParamObj;
self.selectFinanceItem(data);
}
});
$("#formFinance").valid();
} self.saveFinance = function () {
//$("#formFinance").validate({
// rules: {
// fFinanceName: { required: true },
// fLoanCount: { required: true ,min:0}
// },
// messages: {
// fFinanceName: {
// required: "必填",
// },
// fLoanCount: {
// required: "必填",
// },
// fRate: {
// required: "必填",
// },
// fFee: {
// required: "必填",
// },
// fPeriod: {
// required: "必选",
// }
// },
// errorPlacement: function (error, element) {
// var p = $("<p class='errmsg'>");
// p.append(error);
// p.appendTo(element.parent());
// }
//});
if ($("#formFinance").valid()) {
if (!financeFlag) {
financeFlag = true;
o = self.selectFinanceItem(); //if (o.FinanceName == '' || o.FinanceName == null) {
// alert("请输入融资名称!"); financeFlag = false; return false;
//}
//if (o.LoanCount <= 0) {
// alert("请输入融资金额!"); financeFlag = false; return false;
//}
//if (o.Rate <= 0) {
// alert("请输入贷款利率!"); financeFlag = false; return false;
//}
//if (o.Fee <= 0) {
// alert("请输入手续费!"); financeFlag = false; return false;
//}
//if (o.Period <= 0) {
// alert("请输入期数!"); financeFlag = false; return false;
//}
o.CreateBy = userid;
o.UpdateBy = userid;
var msg = "";
var type = "";
var api = "";
if (o.ID == null) {
msg = "添加成功!"; type = "post"; api = "InsertFinancing"; o.CreateTime = GetNow(); o.UpdateTime = GetNow();
} else {
msg = "更新成功!";
type = "put"; api = "UpdateFinancing"; o.UpdateTime = GetNow();
}
isT = false;
$.ajax({
url: "/api/CommonApi?API=GetFinancingByFinanceName",
type: "get",
async: false,
data: { FinanceName: o.FinanceName },
dataType: "json",
success: function (data) {
var len = data.ApiParamObj.length;
if (len > ) {
var id = data.ApiParamObj[].ID;
if (id != o.ID) {
Alert("该融资名称已存在!").on(function() {
isT = true; financeFlag = false;
self.goToPage();
$('#dvFinance').modal('hide');
});
}
}
}
});
if (!isT) {
$.ajax({
url: "/api/CommonApi?API=" + api,
type: type,
data: { ApiParamObj: JSON.stringify(o) },
dataType: "json",
success: function (data) {
console.dir(data);
if (data.Success) {
Alert(msg).on(function () {
self.goToPage();
$('#dvFinance').modal('hide');
})
}
financeFlag = false;
}
});
}
}
}
}
}
//InsuranceType
self.convertIsForce = function (o) {
if (o) {
return "是";
} else {
return "否";
}
}
self.addInsuranceType = function (o) {
self.selectInsuranceTypeItem(new InsuranceType());
$("#formInsuranceType").valid();
}
self.removeInsuranceType = function (o) {
Confirm('你确定要删除该记录吗?').on(function () {
o.IsDelete = ;
o.UpdateTime = GetNow();
$.ajax({
url: "/api/CommonApi?API=UpdateInsuranceType",
type: "put",
data: { ApiParamObj: JSON.stringify(o) },
dataType: "json",
success: function (data) {
console.dir(data);
if (data.Success) {
Alert("删除成功").on(function () {
self.goToPage();
})
}
}
});
});
}
self.editInsuranceType = function (o) {
$.ajax({
url: "/api/CommonApi?API=GetInsuranceTypeByID",
type: "get",
data: { ID: o.ID },
dataType: "json",
success: function (data) {
console.dir(data);
data = data.ApiParamObj;
self.selectInsuranceTypeItem(data);
}
});
$("#formInsuranceType").valid();
} self.saveInsuranceType = function () {
if ($("#formInsuranceType").valid()) {
if (!insuranceTypeFlag) {
insuranceTypeFlag = true;
o = self.selectInsuranceTypeItem();
//if ($.trim(o.InsuranceName) == "") {
// alert("请输入保险名称!"); insuranceTypeFlag = false; return false;
//}
//if (o.InsuranceMoney <= 0) {
// alert("请输入保险金额!"); insuranceTypeFlag = false; return false;
//}
//if ($.trim(o.InsuranceDesc) == "") {
// alert("请输入保险描述!"); insuranceTypeFlag = false; return false;
//}
var msg = "";
var type = "";
var api = "";
if (o.ID == null) {
msg = "添加成功!"; type = "post"; api = "InsertInsuranceType"; o.CreateTime = GetNow(); o.UpdateTime = GetNow();
} else {
msg = "更新成功!"; type = "put"; api = "UpdateInsuranceType"; o.UpdateTime = GetNow();
}
o.CreateBy = userid;
o.UpdateBy = userid;
$.ajax({
url: "/api/CommonApi?API=" + api,
type: type,
data: { ApiParamObj: JSON.stringify(o) },
dataType: "json",
success: function (data) {
console.dir(data);
if (data.Success) {
Alert(msg).on(function () {
self.goToPage();
$('#dvInsuranceType').modal('hide');
})
}
insuranceTypeFlag = false;
}
});
}
}
} self.Refresh = function (pageIndex) {
if (pageIndex == undefined)
pageIndex = ;
var data = {};
data.sorts = " UpdateTime desc ";
data.pagesize = self.pageSize;
data.page = pageIndex;
var val = self.selectTab();
if (val == ) {
data.API = "GetFinancing";
} else if (val == ) {
data.API = "GetInsuranceType";
}
$.ajax({
url: "/api/CommonApi",
type: "get",
data: data,
dataType: "json",
success: function (datas) {
//console.dir(datas);
var list = datas.ApiParamObj[];
if (val == ) {
self.FinanceList(list);
} else if (val == ) {
self.InsuranceTypeList(list);
}
self.total(datas.ApiParamObj[][].totalRow);
self.caculatePages();
//return datas;
}
});
}
}
var vm = new model();
paginationViewModel.call(vm, );
vm.caculatePages();
vm.goToPage();
ko.applyBindings(vm);
})

分页的js代码:

function paginationViewModel(pageSize) {
if (pageSize==) {
pageSize = ;
}
var self = this;
self.pagerCount =; //如果分页的页面太多,截取部分页面进行显示,默认设置显示9个页面
self.pageSize = pageSize; //每页显示的记录数
self.currentPage = ko.observable(); //当前页面Index
self.jumpPage = ko.observable(); //需要跳转的页面的Index
self.pageCount = ko.observable(); //总页数
self.showStartPagerDot = ko.observable(false); //页面开始部分是否显示点号
self.showEndPagerDot = ko.observable(false); //页面结束部分是否显示点号
self.pages = ko.observable([]); //需要显示的页面数量
self.total = ko.observable(); //记录总数
self.dataLength = ko.observable();
self.start = ko.observable();
self.end = ko.observable();
self.pageCount = ko.computed(function () {
return Math.ceil(self.total() / self.pageSize);
});
//计算需要显示的页面的页码
self.caculatePages = function () { var result = [], pagerCount = self.pagerCount, start = , end = pagerCount;
if (self.currentPage() > pagerCount) {
start = self.currentPage() - Math.floor(pagerCount / );
self.showStartPagerDot(true);
if (start == ) {
self.showStartPagerDot(false);
}
} else {
self.showStartPagerDot(false);
};
end = start + pagerCount - ;
if (end >= self.pageCount()) {
var num = end - self.pageCount();
end = self.pageCount();
start = start - num;
if (start <= ) {
start = ;
}
self.showEndPagerDot(false);
} else {
self.showEndPagerDot(true);
};
self.start(start);
self.end(end);
for (var i = start; i <= end; i++) {
result.push(i);
};
self.pages(result);
}; //总页数
self.formatedPageCount = ko.computed(function () {
return "共" + self.pageCount() + "页";
});
//总记录数
self.formatedItemCount = ko.computed(function () {
return "共" + self.total() + "条数据";
});
//页面跳转
self.goToPage = function (page) {
self.Refresh(page);
// self.pageCount(Math.ceil(self.total() / self.pageSize));
self.currentPage(page);
self.jumpPage(null);
// self.caculatePages();
};
//回到首页
self.goToFirst = function () {
self.goToPage();
};
//跳转到最后一页
self.goToLast = function () {
self.goToPage(Math.ceil(self.total() / self.pageSize));
};
//上一页
self.goToPrev = function () {
var cur = self.currentPage();
if (cur > ) {
self.goToPage(cur - );
};
};
//下一页
self.goToNext = function () {
var cur = self.currentPage();
if (cur < self.pageCount()) {
self.goToPage(cur + );
};
};
self.StartPageDot = function () {
var page = self.start() - Math.floor(self.pagerCount / );
if (page < ) {
page = ;
}
self.goToPage(page);
}
self.EndPageDot = function () {
var page = self.end() + Math.floor(self.pagerCount / );
if (page > self.pageCount()) {
page = self.pageCount();
}
self.goToPage(page);
}
//跳转
self.jump = function () {
var page = self.jumpPage();
if (page > && page <= self.pageCount()) {
self.goToPage(page);
};
};
};

分页使用时,要给ViewModel添加Refresh方法,具体的js代码里面有

分页也要用两部分的html代码,分别在上面的html中有

这里再显示一些

 <div class="row  datatables_paginate paging_full_numbers" style="text-align:center;" data-bind="visible: pages().length > 0">
<div class="small-12 columns" data-bind="template: 'PaginationTemplate'"></div>
</div>
<script type="text/html" id="PaginationTemplate">
<ul class="pagination" data-bind="visible: pages().length > 0">
<li><a data-bind="click: goToFirst"><<</a></li>
<li><a data-bind="click: goToPrev"><</a></li>
<!--ko if:showStartPagerDot-->
<li><a data-bind="click:StartPageDot">...</a></li>
<!--/ko-->
<!--ko foreach:pages-->
<li data-bind="css: { 'active': $data == $parent.currentPage() }">
<a data-bind="text: $data, click: $parent.goToPage.bind($data, $data)"></a>
</li>
<!--/ko-->
<!--ko if:showEndPagerDot-->
<li><a data-bind="click:EndPageDot">...</a></li>
<!--/ko-->
<li><a data-bind="click: goToNext">></a></li>
<li><a data-bind="click: goToLast">>></a></li>
</ul>
</script>

效果:

Knockout 模板使用的更多相关文章

  1. MVC MVVM Knockout 常遇问题总结

    1.模板绑定(使用插件jquery.tmpl) var ViewModel={Product:ko.observable()} <div data-bind="template:{na ...

  2. 【Knockout.js 学习体验之旅】(3)模板绑定

    本文是[Knockout.js 学习体验之旅]系列文章的第3篇,所有demo均基于目前knockout.js的最新版本(3.4.0).小茄才识有限,文中若有不当之处,还望大家指出. 目录: [Knoc ...

  3. Knockout应用开发指南 第四章:模板绑定

    原文:Knockout应用开发指南 第四章:模板绑定 模板绑定The template binding 目的 template绑定通过模板将数据render到页面.模板绑定对于构建嵌套结构的页面非常方 ...

  4. 动动手,写个knockout的分页模板

    最近一个项目用ASP.NET + knockout开发,很多列表页面都带分页,于是就有了写一个公共的分页模板的想法. 先把template写好: <script type="text/ ...

  5. KnockOut文档--模板绑定

    目的 模板绑定使用数据render模板,然后把渲染的结果填充到Dom树中.模板通过重复或嵌套块(通常为您的视图模型数据的函数)用一种简单,方便的方式来建立复杂的UI结构 . 有两种方式使用模板: Na ...

  6. require.js+knockout.js+.underscore模板引擎的使用

    第一种使用方式: HTML: <ul data-bind="template: { name: 'peopleList' }"></ul> <scri ...

  7. knockout.js模板绑定之利用Underscore.js模板引擎示例

    View代码 <h1>People</h1> <ul data-bind="template: { name: 'peopleList' }"> ...

  8. Knockout学习之模板绑定器

    模板绑定器 如今页面结构越来越复杂,仅仅依靠foreach已经不足以我们的使用,这个时候我们就需要模板的存在,模板的优点自然很多,首先会让页面整洁,同时修改起来也可以方面的定位,最重要的是ko可以条件 ...

  9. Knockout学习,添加模板,事件,Mouseover,mouseout

    <div class="rtitle">我的收藏</div> <div class="list_ul" data-bind=&qu ...

随机推荐

  1. MQTT的学习研究(十二) MQTT moquette 的 Future API 消息发布订阅的实现

    MQTT moquette 的Server发布主题 package com.etrip.mqtt.future; import java.net.URISyntaxException; import  ...

  2. dubbo有什么作用

    转自:http://blog.csdn.net/ichsonx/article/details/39008519 1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的R ...

  3. Android - 获取SD卡的内存空间大小

    获取SD卡的内存空间大小 //获得SD卡空间的信息 File path=Environment.getExternalStorageDirectory(); StatFs statFs=new Sta ...

  4. log4j配置输出到多个日志文件(转)

    參考资料:http://logging.apache.org/log4j/1.2/manual.html 通常我们项目里,有一些重要的日志想单独的输出到指定的文件,而不是全总输出到系统的日志文件中.那 ...

  5. RedisDesktopManager 打开报0xc000007b程序错误

    RedisDesktopManager 是一个管理redis的工具,很好用,我的电脑可以安装0.8.3版的,最新版到0.9.4了,其中经典版本是0.8.8,可惜0.8.3版之后,我的电脑安装软件后,打 ...

  6. POI官网中的例子

    官方指南中的例子: http://poi.apache.org/spreadsheet/quick-guide.html#New+Sheet 这一节 Workbook wb = new HSSFWor ...

  7. php curl采集数据问题汇总

    1. 使用curl获取网页数据提示: "curl: (6) Could not resolve host: xxx.xxx.com ; Name or service not known&q ...

  8. arpa/inet.h所引起的Segmentation fault及网络编程常见的头文件

    最近在学习Linux网络编程方面的知识,感觉还是有些困难.主要是对协议过程的理解,还有socket的API的理解不够深刻.今天复习编写了一个TCP的服务端和客户端的程序实现client.c从命令行参数 ...

  9. 【Python】两个for循环嵌套练习

    要求:取下方篮框中内容并写入csv文件中.用两个for循环将每一行取出来作为一个元素存放到新数组中. # coding=utf-8 from selenium import webdriver fro ...

  10. 【Python】读取各种文档(txt、csv、excel、pdf)方法

    1.读取txt文件 注意事项: 1..txt文件同下方脚本所在的.py文件需要在同一个文件夹下 # coding=utf-8 txt读取 with open("1233.txt") ...