1月13日

泄露秘密 提交于 2020-01-22 19:14:24

1.时间比较验证

Struts中的下拉列表标签的使用 
页面中经常用到下拉列表,下面是个人对于STRUTS中标签使用的一点总结: 
STRUTS中的下拉选择列表标签必须嵌套在<html:form>标签中,包括: 
1.<html:select> 
2.<html:option> 
3.<html:options> 
4.<html:optionsCollection> 

使用时嵌套如下: 
<html:select property="ationForm.property"> 
<html:option>或<html:options>或<html:optionsCollection> 
</html:select> 
其中property为ActionForm中对应的一个属性. 

1.<html:option> 
<html:option value="value">displayName</html:option> 
其中value为实际使用的值(赋值到ActionForm对应的属性中) displayName页面中显示的信息.
例:<html:option value=""></html:option>显示一个空白选择,值为"". 

2..<html:options> 
<html:options collection="collection" labelProperty="displayName" property="value"/> 
其中collection为一个集合,一般是个ArrayList,displayName为前台显示的名称,value为后台实际使用的值. 
例:<html:options collection="arrayList" labelProperty="name" property="id" /> 

3..<html:optionsCollection> 
<html:optionsCollection property="actionForm.property" label="displayName" value="value"/> 
其中property为ActionForm中的一个属性,为一个集合.displayName为前台显示的名称,value为后台实际使用的值. 
例:<html:optionsCollection property="listProperty" label="name" value="id" /> 

补充一点:如果要从 数据库去取数据,一般是在 action 里调用 DAO ,把结果存入一个ArrayList作为 request 的一个属性传到页面上; 这时一般用 <html:options .../> 标签.另外,如果数据不从数据库去取,而是代码固定的,则一般把这种放到 ActionForm 里,作为属性在页面上取,这时一般用 <html:optionsCollection ... />

 

function compareTime()
	{
	var resultFlag=false
	
	var openTimeHour=parseInt(document.getElementById("openTimeHour").value,10);

	var openTimeMin=parseInt(document.getElementById("openTimeMin").value,10);
	var closeTimeHour=parseInt(document.getElementById("closeTimeHour").value,10);
	var closeTimeMin=parseInt(document.getElementById("closeTimeMin").value,10);
	if((openTimeHour<closeTimeHour)||((openTimeHour==closeTimeHour)&&(openTimeMin<closeTimeMin)))
	{
		resultFlag=true;
		
	}
	
	if(resultFlag==false){
		alert("<bean:message key="CM_ERR000055"/>");
	}
	
	return resultFlag;
	}

2.js的push方法

push   方法   
  将新元素添加到一个数组中,并返回数组的新长度值。   
    
  arrayObj.push([item1   [item2   [.   .   .   [itemN   ]]]])   
    
  参数   
  arrayObj   
    
  必选项。一个   Array   对象。   
    
  item,   item2,.   .   .   itemN   
    
  可选项。该   Array   的新元素。   
    
  说明   
  push   方法将以新元素出现的顺序添加这些元素。如果参数之一为数组,那么该数组将作为单个元素添加到数组中。如果要合并两个或多个数组中的元素,请使用   concat   方法。   
    
    
  */   
  Array.prototype.push=function(){   
          var   len=arguments.length;   
          if(len>0)for(var   i=0;i<len;i++)this[this.length]=arguments[i];   
          return   this.length;   
          }   
  var   a=[1,2,3,4]   
  a.push(5)   
  alert(a)   
  alert(a.push(6))</script>  

3.按钮跳转:

正确的

<html:button property="btnCancel" style="width:60px" onclick="history.back();">
		<bean:message key="CM_LAB_BTN_CANCEL" />
	</html:button>

错误的 

<html:button property="btnCancel" style="width:60px" onclick="window.back();">
		<bean:message key="CM_LAB_BTN_CANCEL" />
	</html:button>

  

这里在本页实现跳转使用history.go(-1)或是history.back() window.XXX只适合页面跳转时使用.

 

4.时间验证


 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!