
Markdown是一種輕量級的標籤語言
資料敘事
Let Test it!
Written with StackEdit.
工程師的價值在於處理這些看似不起眼點卻又至關重要的小地方! 本網誌僅做個人生涯知識累積之用, 禁止將該網誌之內容做為營利之用
<iframe id='iframe1' src='../test.jsp' width='95%' height='400' frameborder='0' onload='Javascript:SetCwinHeight(iframe1)'><script type="text/javascript">
/**iframe根據載入內容自動控制高度~ **/
function SetCwinHeight(sId){
var bobo=document.getElementById(sId); //iframe id
if (document.getElementById){
if (bobo && !window.opera){
if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
bobo.height = bobo.contentDocument.body.offsetHeight+50;
if(bobo.height <= 350 ){
bobo.height = 350;
}
}else if(bobo.Document && bobo.Document.body.scrollHeight){
bobo.height = bobo.Document.body.scrollHeight+50;
if(bobo.height <= 350 ){
bobo.height = 350;
}
}
}
}
}
</script>
/**JSON 吃Boolean陣列*/
public JSONArray booleanTest(){
boolean[] boolArray = new boolean[]{true,false,true};
JSONArray boolJsonArr = JSONArray.fromObject(boolArray);
return boolJsonArr;
}/**JSON 吃Boolean陣列*/
JSONArray boolJsonArr = jsonTest.booleanTest();
System.out.println("boolJsonArr=" + boolJsonArr);public JSONArray listTest(){
/**
* Json的真面目
* JSONArray jsonArray = JSONArray.fromObject("['測試0','測試1','測試2','測試3']");
* **/
/**做資料*/
List listArr = new ArrayList();
for(int i=0; i<10; i++){
listArr.add(i, "測試"+i);
} /**將List資料用Json物件接收*/
JSONArray listJsonArr = JSONArray.fromObject(listArr);
return listJsonArr;
} /**JSON 吃List陣列*/
JSONArray listJsonArr = jsonTest.listTest();
System.out.println("listJsonArr=" + listJsonArr); public JSONObject mapTest(){
/**做map資料*/
Map map = new HashMap();
map.put("name","shaw");
map.put("bool", Boolean.TRUE);
map.put("int", new Integer(1));
map.put("arr", new String[]{"a","b"});
map.put("func", "function(i){ return this.arr[i]; }");
/**將Map資料用JSon物件接收*/
JSONObject mapTestObj = JSONObject.fromObject(map);
return mapTestObj;
}/**JSON 吃HashMap*/
JSONObject mapTestObj = jsonTest.mapTest();
System.out.println("mapTestObj=" + mapTestObj);package org.shaw.MyDao;
public class FormTest {
/**
* @author Shaw Wu
* 建立測試表單用
*/
private Integer id;
private String name;
private String password;
private Integer age;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}/**JSON 吃Bean*/
public JSONObject beanTest(){
/**new出Bean資料*/
/**import org.shaw.MyDao.FormTest;**/
FormTest formTest = new FormTest();
formTest.setId(1);
formTest.setName("Shaw");
formTest.setPassword("12345");
formTest.setAge(18);
/**將Bean資料用JSon物件接收*/
JSONObject beanTestObj = JSONObject.fromObject(formTest);
return beanTestObj;
}/**JSON 吃Bean*/
JSONObject beanTestObj = jsonTest.beanTest();
System.out.println("beanTestObj=" + beanTestObj);
System.out.println(beanTestObj.get("age"));//單取一個Key值<link rel="stylesheet" href="themes/base/jquery.ui.all.css">
<script src="jquery/jquery-1.5.1.js"></script>
<script src="ui/jquery.ui.core.js"></script>
<script src="ui/jquery.ui.widget.js"></script>
<script src="ui/jquery.ui.tabs.js"></script><div class="demo">
<div id="tabs">
<ul>
<li><a id="title1" href="#tabs-1">服務1</a></li>
<li><a id="title2" href="#tabs-2">服務2</a></li>
<li><a id="title3" href="#tabs-3">服務3</a></li>
</ul>
<div id="tabs-1"></div>
<div id="tabs-2"></div>
<div id="tabs-3">
<p>第一行.</p>
<p>第二行.</p>
</div>
</div><!-- End tabs --><script>
$(function() {
/**Tabs*/
$( "#tabs" ).tabs(); /**嵌入Iframe*/
$("#title1").click(function(){
var iframeStr = "<iframe src='iframeTest.jsp' width='90%'
height='300'frameborder='0'>";
$("#tabs-1").html(iframeStr);
})
/**嵌入Iframe*/
$("#title2").click(function(){
var iframeStr = "<iframe src='ajaxChild.jsp?serviceId="+$("#serviceId").val()
+"'width='90%' height='300' frameborder='0'>";
alert("tabs-2");//test
$("#tabs-2").html(iframeStr);
})
});//$(function() {
</script> <form id="form_data" name="form_data" action="IQueryTabs.jsp" Method="post">
<INPUT TYPE="hidden" id="serviceId" name="serviceId" value="<%=serviceId+1%>" />
</form>
CODE {
display: block; /* fixes a strange ie margin bug */
font-family: Courier New;
font-size: 8pt;
overflow:auto;
background: #f0f0f0 url(http://klcintw.images.googlepages.com/Code_BG.gif) left top repeat-y;
border: 1px solid #ccc;
padding: 10px 10px 10px 21px;
max-height:200px;
line-height: 1.2em;
}這樣就大公告成啦~
<%-- 使用JSTL --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><TABLE border="0">
<c:forEach items="<%=serviceName%>" var="service" >
<tr>
<td>
${service}</br>
</td>
</tr>
</c:forEach>
</TABLE><TABLE border="0">
<c:set value="<%=titleAlia%>" var="Alias" />
<c:forEach items="<%=serviceName%>" var="service" varStatus="count">
<tr>
<td class="navtwo-2">
${service}${Alias[count.count-1]}</br>
</td>
</tr>
</c:forEach>
</TABLE>