PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
//王大爷有6只乌龟,它们的体重分别是3kg,5kg,1kg,
//3.4kg,2kg,50kg 。请问这六只乌龟的总体重是少?
//平均体重是多少? 请你用现在掌握的技术编一个程序解决
/*
var weight=[3.4,2,50];
var total=0;
//alert(weight);
//alert(weight.length);
for(var i=0;i<weight.length;i++){
total +=weight[i];
}
//toFixed方法:把数字转换为字符串,结果的小数点后有指定位数的数字
alert("总体重为:"+total+" "+"平均体重为:"+(total/weight.length).toFixed(2));
*/
/*
//数组在函数中传递是地址
var weight=[20,45,80];
alert("函数调用前:"+weight);
function test(arr){
//weight[0]=50;
weight=null;
}
test(weight);
alert("函数调用后:"+weight);
*/
/* var a =[2,3];
a[3]=6;
//alert(a[2]);
var str ="hello wo men zai";
var arr=str.split(" ",3);
alert(typeof(arr));
*/
//遍历一维数组
// var arr=[1.22,20,"hello",90,"world"];
/*
//for 循环
for(var i=0;i<arr.length;i++){
document.writeln(arr[i]);
}*/
/*
//while
var i=0
while(i<arr.length){
document.writeln(arr[i]);
i++;
}*/
//do...while
/* var i=0;
do{
document.writeln(arr[i]);
i++;
}while(i<arr.length);
*/
//for [other]
/*
for(var key in arr){
document.writeln(arr[key]);
}
*/
//多维数组---二维数组
var arr=[["beijing",123,4.5],["a","b","c"]];
//var arr=[[0,0,0,0,0,0],[0,0,1,0,0,0],[0,2,0,3,0,0],[0,0,0,0,0,0]]
//alert(arr[0][0]);
//遍历二维数组
//alert(arr.length);//为2
//alert(arr[2]);
//alert(arr[2][2]);
for(var i=0;i<arr.length;i++){
//var arr2=arr[i];
for(var j=0;j<arr[i].length;j++){
document.writeln(arr[i][j]);
}
document.writeln("<br/>");
}
</script>
</head>
<body>
</body>
</html>
自己多动手写,并且在写的过程中思考,慢慢的就能理解了。
本文链接
就上一篇所说的,按道理应该先说说用三种方式(类式继承、原型式继承、掺元式继承)分别实现edit-in-place。懒得敲代码了,所以就用最常用的类式继承实现。其余两种方法就先不说了,如果大家都想看到的话,那我再修改,贴出来吧。最近需要准备实习,完善简历,大街网上得填写简历去,不知道博客园里面是否会有猎头看到这篇文章,那顺便宣传一下,大街网-搜索-哈尔滨工业大学-刘平,就可以找到我,如果大家有好的实习单位,也可以给我私信。
* @author tonylp
*/
function EditInPlaceField(id,parent,value){
this.id = id;
this.parentElement = parent;
this.value = value || 'default value';
this.createElements(this.id);
this.attachEvents();
};
EditInPlaceField.prototype = {
createElements:function(id){
this.containerElement = document.createElement('div');
this.parentElement.appendChild(this.containerElement);
this.staticElement = document.createElement('span');
this.containerElement.appendChild(this.staticElement);
this.staticElement.innerHTML = this.value;
this.fieldElement = document.createElement('input');
this.fieldElement.type = 'text';
this.fieldElement.value = this.value;
this.containerElement.appendChild(this.fieldElement);
this.saveButton = document.createElement('input');
this.saveButton.type = 'button';
this.saveButton.value = 'Save';
this.containerElement.appendChild(this.saveButton);
this.cancelButton = document.createElement('input');
this.cancelButton.type = 'button';
this.cancelButton.value = 'Cancel';
this.containerElement.appendChild(this.cancelButton);
this.convertToText();
},
attachEvents:function(){
var that = this;
addEvent(this.staticElement,'click',function(){that.convertToEditable();});
addEvent(this.saveButton,'click',function(){that.save();});
addEvent(this.cancelButton,'click',function(){that.cancel();});
},
convertToEditable:function(){
this.staticElement.style.display = 'none';
this.fieldElement.style.display = 'inline';
this.saveButton.style.display = 'inline';
this.cancelButton.style.display = 'inline';
this.setValue(this.value);
},
save:function(){
this.value = this.getValue();
var that = this;
var callback = {
success:function(){that.convertToText();},
failure:function(){alert('Error saving value.');}
};
ajaxRequest('get','save.php?id='+this.id+'&value='+this.value,callback);
},
cancel:function(){
this.convertToText();
},
convertToText:function(){
this.fieldElement.style.display = 'none';
this.saveButton.style.display = 'none';
this.cancelButton.style.display = 'none';
this.staticElement.style.display = 'inline';
this.setValue(this.value);
},
setValue:function(value){
this.fieldElement.value = value;
this.staticElement.innerHTML = value;
},
getValue:function(){
return this.fieldElement.value;
}
};
//要创建一个就地编辑域,只需要实例化这个类即可
var titleClassical = new EditInPlaceField('titleClassical',$('doc'),'Title Here');
var currentTitleText = titleClassical.getValue();
//接下来我们要创建一个使用多行文本框而不是单行文本框的类,这个EditInPlaceArea类,这个类继承了EditInPlaceField
function EditInPlaceArea(id,parent,value){
EditInPlaceArea.superclass.constructor.call(this,id,parent,value);
};
extend(EditInPlaceArea,EditInPlaceField);
EditInPlaceArea.prototype.createElements = fu
IOC:
DAO Service Action都需要交给spring进行管理,并且注入。
AOP: 未???
spring和struts如何结合: spring容器在web启动的时候启动。要让struts去控制已经由spring创建和管理的action(也就是struts和spring结合),加入plugin.jar
究竟如何整合的呢:
plugin.jar里面有一个struts-plugin.xml文件:
<struts>
<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring" class="org.apache.struts2.spring.StrutsSpringObjectFactory" />
<!-- Make the Spring object factory the automatic default -->
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.class.reloading.watchList" value="" />
<constant name="struts.class.reloading.acceptClasses" value="" />
<constant name="struts.class.reloading.reloadConfig" value="false" />
<package name="spring-default">
<interceptors>
<interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
<interceptor name="sessionAutowiring" class="org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor"/>
</interceptors>
</package>
</struts>
工厂类创建,在struts要找action实例的时候,会找spring拿,spring的factory会找到spring配置文件,找到bean。所以会根据struts的action 的name去spring中找相同名字的bean。