Memory Leak 記憶體漏洩
2014年4月15日 星期二
2014年4月14日 星期一
application/x-www-form-urlencoded
Jquery ajax contentType 預設為: 'application/x-www-form-urlencoded; charset=UTF-8'
可用有:
要注意:如果不是使用 application/x-www-form-urlencoded 在Servlet端 無法從request.getparameter(key),取回資料,只能從StreamInput中取得。
form 的enctype 發送格式預設是 :'application/x-www-form-urlencoded;
可用有:
可用有:
- application/x-www-form-urlencoded
- application/json
- text/xml
要注意:如果不是使用 application/x-www-form-urlencoded 在Servlet端 無法從request.getparameter(key),取回資料,只能從StreamInput中取得。
form 的enctype 發送格式預設是 :'application/x-www-form-urlencoded;
可用有:
- application/x-www-form-urlencoded
- multipart/form-data
- text/plain
jsrender 範例
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="author" content="hua" />
<script src="../js/jquery-1.8.1.min.js"></script>
<script src="../js/jsrender.min.js"></script>
<style>
.table201404120200{
}
.table201404120200 td{
border: solid 1px #CCCCCC;
}
</style>
</head>
<body>
<div id="content20140412">
</div>
<!--jsrender 樣板宣告 (主樣板)-->
<script id="mainTmpl201404120200" type="text/x-jsrender">
<table width="400px" class='table201404120200'>
<thead>
<tr ><th colspan="4">{{:title}}</th></tr>
</thead>
<tbody>
<tr>
<td>品名</td>
<td>數量</td>
<td>成本</td>
<td>售價</td>
<td>價差</td> <!--呼叫 js method-->
<td>價差*2</td>
<td>index</td>
<td>color</td>
</tr>
</tr>
{{for data tmpl="#reportTmpl201404120200" /}}
</tbody>
</table>
</script>
<!--jsrender 樣板宣告 (子樣板)-->
<script id="reportTmpl201404120200" type="text/x-jsrender">
<tr>
<td>{{: nam }}</td>
<td>{{: quantity }}</td>
<td>{{: cost }}</td>
<td>{{: price}}</td>
<td>{{: ~method( price , cost)}}</td> <!--呼叫 js method-->
<td>{{: ~method( price , cost) * 2}}</td> <!--呼叫 js method-->
<td>{{: #index }}</td>
{{if #index % 2 == 0}}
<td style="background:#FF0080 ">#FF0080</td>
{{else}}
<td style="background:#FF8000 ">#FF8000</td>
{{/if}}
</tr>
</script>
<script>
(function(){
//資料,以資料驅動畫面
var report = {
title : '貨品資訊列表',
data : [
{
nam : '精工表',
quantity : 2,
cost : 10000,
price : 30000,
},
{
nam : '魯夫公仔',
quantity : 20,
cost : 100,
price : 399,
},
{
nam : 'RX-78 RG 1/144',
quantity : 10,
cost : 500,
price : 1000,
}
]
};
function difference(price, cost){
return price - cost;
}
var html = $("#mainTmpl201404120200").render(report , {method : difference});
//console.log(html);
$('#content20140412').html(html);
})();
</script>
</body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="author" content="hua" />
<script src="../js/jquery-1.8.1.min.js"></script>
<script src="../js/jsrender.min.js"></script>
<style>
.table201404120200{
}
.table201404120200 td{
border: solid 1px #CCCCCC;
}
</style>
</head>
<body>
<div id="content20140412">
</div>
<!--jsrender 樣板宣告 (主樣板)-->
<script id="mainTmpl201404120200" type="text/x-jsrender">
<table width="400px" class='table201404120200'>
<thead>
<tr ><th colspan="4">{{:title}}</th></tr>
</thead>
<tbody>
<tr>
<td>品名</td>
<td>數量</td>
<td>成本</td>
<td>售價</td>
<td>價差</td> <!--呼叫 js method-->
<td>價差*2</td>
<td>index</td>
<td>color</td>
</tr>
</tr>
{{for data tmpl="#reportTmpl201404120200" /}}
</tbody>
</table>
</script>
<!--jsrender 樣板宣告 (子樣板)-->
<script id="reportTmpl201404120200" type="text/x-jsrender">
<tr>
<td>{{: nam }}</td>
<td>{{: quantity }}</td>
<td>{{: cost }}</td>
<td>{{: price}}</td>
<td>{{: ~method( price , cost)}}</td> <!--呼叫 js method-->
<td>{{: ~method( price , cost) * 2}}</td> <!--呼叫 js method-->
<td>{{: #index }}</td>
{{if #index % 2 == 0}}
<td style="background:#FF0080 ">#FF0080</td>
{{else}}
<td style="background:#FF8000 ">#FF8000</td>
{{/if}}
</tr>
</script>
<script>
(function(){
//資料,以資料驅動畫面
var report = {
title : '貨品資訊列表',
data : [
{
nam : '精工表',
quantity : 2,
cost : 10000,
price : 30000,
},
{
nam : '魯夫公仔',
quantity : 20,
cost : 100,
price : 399,
},
{
nam : 'RX-78 RG 1/144',
quantity : 10,
cost : 500,
price : 1000,
}
]
};
function difference(price, cost){
return price - cost;
}
var html = $("#mainTmpl201404120200").render(report , {method : difference});
//console.log(html);
$('#content20140412').html(html);
})();
</script>
</body>
2014年1月13日 星期一
javascript 雙向鍊結串列 LIST
雙向鍊結串列
<!DOCTYPE >
<html lang="zh-TW">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>List 雙向鍊結</title>
<meta name="description" content="" />
<meta name="author" content="hua" />
<style>
</style>
</head>
<body>
<input type="button" value="建立時間比較" id="btn1"/>
<input type="button" value="移除時間比較" id="btn2"/>
<!--
一開始設計在Node中有 index 屬性
但很明顯的在從最前端移除後,要對每一個節點從算index
如此很耗效能
於似乎思考,java的鍊結串列也有index可是效能很好怎麼做到的.
於是想到,node根本不需要Index,index只是用來做拜訪node的條件.
因此在重新修改一次
-->
<script type="text/javascript">
(function(window){
function getList(){
function List(){
var firstNode=null;
var lastNode=null;
var count=0;
var getNode = function(leftNode, rightNode, val){
return{
'left':leftNode,
'right':rightNode,
'value':val,
'destory':function(){
this.left = null;
this.right = null;
this.value = null;
}
};
}
<!DOCTYPE >
<html lang="zh-TW">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>List 雙向鍊結</title>
<meta name="description" content="" />
<meta name="author" content="hua" />
<style>
</style>
</head>
<body>
<input type="button" value="建立時間比較" id="btn1"/>
<input type="button" value="移除時間比較" id="btn2"/>
<!--
一開始設計在Node中有 index 屬性
但很明顯的在從最前端移除後,要對每一個節點從算index
如此很耗效能
於似乎思考,java的鍊結串列也有index可是效能很好怎麼做到的.
於是想到,node根本不需要Index,index只是用來做拜訪node的條件.
因此在重新修改一次
-->
<script type="text/javascript">
(function(window){
function getList(){
function List(){
var firstNode=null;
var lastNode=null;
var count=0;
var getNode = function(leftNode, rightNode, val){
return{
'left':leftNode,
'right':rightNode,
'value':val,
'destory':function(){
this.left = null;
this.right = null;
this.value = null;
}
};
}
2013年12月8日 星期日
insertion sort
插入排序 insertion sort
Worst case performance :О(n2) comparisons, swaps
Best case performance :O(n) comparisons, O(1) swaps
Average case performance: О(n2) comparisons, swaps
Worst case space complexity: О(n) total, O(1) auxiliary
參考資料:
Worst case performance :О(n2) comparisons, swaps
Best case performance :O(n) comparisons, O(1) swaps
Average case performance: О(n2) comparisons, swaps
Worst case space complexity: О(n) total, O(1) auxiliary
參考資料:
Bubble Sort
氣泡排序 (Bubble Sort)
參考資料:維基百科 bubble sort
最差時間複雜度 (Worst case performance): O(n^2)
最佳時間複雜度 (Best case performance): O(n)
平均時間複雜度 (Average case performance):O(n^2)
最差空間複雜度 (Worst case space complexity): O(1) auxiliary
參考資料:維基百科 bubble sort
最差時間複雜度 (Worst case performance): O(n^2)
最佳時間複雜度 (Best case performance): O(n)
平均時間複雜度 (Average case performance):O(n^2)
最差空間複雜度 (Worst case space complexity): O(1) auxiliary
2013年12月3日 星期二
訂閱:
文章 (Atom)