tinguo002

 

js判断数字-正则表达式(转)

http://blog.sina.com.cn/s/blog_72b7a82d0100yfip.html

"^\\d+$"  //非负整数(正整数  0)   


"^[0-9]*[1-9][0-9]*$"  //正整数   


"^((-\\d+)|(0+))$"  //非正整数(负整数  0)   


"^-[0-9]*[1-9][0-9]*$"  //负整数   


"^-?\\d+$"    //整数   


"^\\d+(\\.\\d+)?$"  //非负浮点数(正浮点数  0)   



"^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$"  //正浮点数
 


"^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$"  //非正浮点数(负浮点数  0)
 



"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"  //负浮点数
 


"^(-?\\d+)(\\.\\d+)?$"  //浮点数



测试:


<script>


function forcheck(ss){


var
type="^[0-9]*[1-9][0-9]*$";

var re = new
RegExp(type);

if(ss.match(re)==null)

{
alert(
"请输入大于零的整数!");

return;
  }


}


</script>

posted @ 2013-07-04 17:59 一堣而安 阅读(222) | 评论 (0)编辑 收藏

ArrayList的toArray(转)


http://www.cnblogs.com/ihou/archive/2012/05/10/2494578.html

ArrayList提供了一个将List转为数组的一个非常方便的方法toArray。toArray有两个重载的方法:

1.list.toArray();

2.list.toArray(T[]  a);

对于第一个重载方法,是将list直接转为Object[] 数组;

第二种方法是将list转化为你所需要类型的数组,当然我们用的时候会转化为与list内容相同的类型。

不明真像的同学喜欢用第一个,是这样写:

1
2
3
4
5
6
7
ArrayList<String> list=new ArrayList<String>();
        for (int i = 0; i < 10; i++) {
            list.add(""+i);
        }
       
        String[] array= (String[]) list.toArray();
      

结果一运行,报错:

Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;

原因一看就知道了,不能将Object[] 转化为String[].转化的话只能是取出每一个元素再转化,像这样:

1
2
3
4
5
Object[] arr = list.toArray();
        for (int i = 0; i < arr.length; i++) {
            String e = (String) arr[i];
            System.out.println(e);
        }

所以第一个重构方法就不是那么好使了。

实际上,将list世界转化为array的时候,第二种重构方法更方便,用法如下:

1
2
String[] array =new String[list.size()];
        list.toArray(array);<br><br>另附,两个重构方法的源码:

1.
public Object[] toArray(); {
Object[] result = new Object[size];
System.arraycopy(elementData, 0, result, 0, size);;
return result;
}

2.

public Object[] toArray(Object a[]); {
if (a.length < size);
a = (Object[]);java.lang.reflect.Array.newInstance(
a.getClass();.getComponentType();, size);;
System.arraycopy(elementData, 0, a, 0, size);;

if (a.length > size);
a[size] = null;

return a;
}

1
<br><br>
1
2
<br>
  

posted @ 2013-07-04 11:52 一堣而安 阅读(234) | 评论 (0)编辑 收藏

js获取项目根路径[转]



http://www.cnblogs.com/linjiqin/archive/2011/03/07/1974800.html
//
js获取项目根路径,如: http://localhost:8083/uimcardprj
function getRootPath(){
    
//获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
    var curWwwPath=window.document.location.href;
    
//获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
    var pathName=window.document.location.pathname;
    
var pos=curWwwPath.indexOf(pathName);
    
//获取主机地址,如: http://localhost:8083
    var localhostPaht=curWwwPath.substring(0,pos);
    
//获取带"/"的项目名,如:/uimcardprj
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    
return(localhostPaht+projectName);
}

posted @ 2013-06-19 16:14 一堣而安 阅读(600) | 评论 (0)编辑 收藏

转]Java中HashMap遍历的两种方式

转]Java中HashMap遍历的两种方式
原文地址: http://www.javaweb.cc/language/java/032291.shtml

第一种:
  Map map = new HashMap();
  Iterator iter = map.entrySet().iterator();
  while (iter.hasNext()) {
  Map.Entry entry = (Map.Entry) iter.next();
  Object key = entry.getKey();
  Object val = entry.getValue();
  }
  效率高,以后一定要使用此种方式!
第二种:
  Map map = new HashMap();
  Iterator iter = map.keySet().iterator();
  while (iter.hasNext()) {
  Object key = iter.next();
  Object val = map.get(key);
  }
  效率低,以后尽量少使用!
 
       HashMap的遍历有两种常用的方法,那就是使用keyset及entryset来进行遍历,但两者的遍历速度是有差别的,下面请看实例:
  public class HashMapTest {
  public static void main(String[] args) ...{
  HashMap hashmap = new HashMap();
  for (int i = 0; i < 1000; i ) ...{
  hashmap.put("" i, "thanks");
  }
  long bs = Calendar.getInstance().getTimeInMillis();
  Iterator iterator = hashmap.keySet().iterator();
  while (iterator.hasNext()) ...{
  System.out.print(hashmap.get(iterator.next()));
  }
  System.out.println();
  System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
  listHashMap();
  }
  public static void listHashMap() ...{
  java.util.HashMap hashmap = new java.util.HashMap();
  for (int i = 0; i < 1000; i ) ...{
  hashmap.put("" i, "thanks");
  }
  long bs = Calendar.getInstance().getTimeInMillis();
  java.util.Iterator it = hashmap.entrySet().iterator();
  while (it.hasNext()) ...{
  java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
  // entry.getKey() 返回与此项对应的键
  // entry.getValue() 返回与此项对应的值
  System.out.print(entry.getValue());
  }
  System.out.println();
  System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
  }
  }
  对于keySet其实是遍历了2次,一次是转为iterator,一次就从hashmap中取出key所对于的value。而entryset只是遍历了第一次,他把key和value都放到了entry中,所以就快了。


Java中HashMap遍历的两种方式(本教程仅供研究和学习,不代表JAVA中文网观点)
本篇文章链接地址:http://www.javaweb.cc/language/java/032291.shtml
如需转载请注明出自JAVA中文网:http://www.javaweb.cc/


还是第一种好,简单。。。

posted @ 2013-06-17 21:59 一堣而安 阅读(204) | 评论 (0)编辑 收藏

Myeclipse安装findbugs(转)

 http://hnwsha.blog.sohu.com/211993316.html
分类: Java 2012-04-17
13:13

安装方法如下:
1、首先从findbugs网站下载插件:http://findbugs.sourceforge.net/downloads.html

2、将下载回来的zip包解压,得到文件夹:edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821,将该文件夹拷贝到myeclipse安装目录下common/plugins目录下。我的目录结构:D:\Genuitec\MyEclipse8.5\Common\plugins\edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821

3、修改myeclipse安装目录下configuration/org.eclipse.equinox.simpleconfigurator的bundles.info文件,在文件最后添加一行:

edu.umd.cs.findbugs.plugin.eclipse,1.3.9.20090821,file:/D:/Genuitec/MyEclipse8.5/Common/plugins/edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821,4,false
注意最后一行不能有空格,回车之类的符号。

这里file后面的路径要根据自己的目录设置进行修改,要不然重启myeclipse后,仍然找不到findbugs。

4、重启myeclipse,选中项目,右键会出现一个Find
Bugs菜单。至此,findbugs插件安装完毕

posted @ 2013-06-17 15:15 一堣而安 阅读(3091) | 评论 (0)编辑 收藏

js网页滚动条滚动事件


http://www.cnblogs.com/yongtaiyu/archive/2012/11/14/2769707.html
js网页滚动条滚动事件

在做js返回顶部的效果时,要监听网页滚动条滚动事件,这个事件就是:window.onscroll。当onscroll事件发生时,用js获得页面的scrollTop值,判断scrollTop为一个设定值时,显示“返回面部”
js网页滚动条滚动事件

<style type="text/css">
#top_div{
    position:fixed;
    bottom:80px;
    right:0;
    display:none;
}
</style>
<script type="text/javascript">
window.onscroll = function(){
    var t = document.documentElement.scrollTop || document.body.scrollTop; 
    var top_div = document.getElementById( "top_div" );
    if( t >= 300 ) {
        top_div.style.display = "inline";
    } else {
        top_div.style.display = "none";
    }
}

</script>
<a name="top">顶部<a>
<div id="top_div"><a href="#top">返回顶部</a></div>
<br />
<br />
<div>
这里尽量多些<br />以便页面出现滚动条,限于篇幅本文此处略去
</div>

例子语法解释
在 style 标签中首先定义 top_div css 属性:position:fixed;display:none; 是关键
javascript 语句中,t 得到滚动条向下滚动的位置,|| 是为了更好兼容性考虑
当滚动超过 300 (像素)时,将 top_div css display 属性设置为显示(inline),反之则隐藏(none)
必须设定 DOCTYPE 类型,在 IE 中才能利用 document.documentElement 来取得窗口的宽度及高度

转自:http://www.altmi.com/zg/index.php/archives/67/

posted @ 2013-06-03 16:35 一堣而安 阅读(519) | 评论 (0)编辑 收藏

iframe 刷新

JS实现刷新iframe的方法



<iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe>


方案一:用iframe的name属性定位


<input type="button" name="Button"
value="Button"
onclick="document.frames('ifrmname').location.reload()">


  或


<input type="button" name="Button"
value="Button"
onclick="document.all.ifrmname.document.location.reload()">


  方案二:用iframe的id属性定位


<input type="button" name="Button"
value="Button"
onclick="ifrmid.window.location.reload()">


  终极方案:当iframe的src为其它网站地址(跨域操作时)


<input type="button" name="Button"
value="Button"
onclick="window.open(document.all.ifrmname.src,'ifrmname','')">





代码如下:<input type=button value=刷新 onclick="history.go(0)">


代码如下:<input type=button value=刷新 onclick="location.reload()">


代码如下:<input type=button value=刷新 onclick="location=location">


代码如下:<input type=button value=刷新
onclick="window.navigate(location)">


代码如下:<input type=button value=刷新 onclick="location.replace(location)">


下面这三种我就不知道该怎么用了,就把代码放在下面吧,哪位要是会的话,可教教大家。


<input type=button value=刷新
onclick="document.execCommand(@#Refresh@#)">


<input type=button value=刷新
onclick="window.open(@#自身的文件@#,@#_self@#)">


<input type=button value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)>






父页面中存在两个iframe,一个iframe中是一个链接列表,其中的链接指向另一个iframe,用于显示内容。现在当内容内容添加后,在链接列表中添加了一条记录,则需要刷新列表iframe。


在内容iframe的提交js中使用parent.location.reload()将父页面全部刷新,因为另一个iframe没有默认的url,只能通过列表选择,所以只显示了列表iframe的内容。


使用window.parent.frames["列表iframe名字"].location="列表url"即可进刷新列表iframe,而内容iframe在提交后自己的刷新将不受影响。








document.frames("refreshAlarm").location.reload(true); //ok


document.frames("refreshAlarm").document.location.reload(true); //ok


document.frames("refreshAlarm").document.location="/public/alarmsum.asp";//ok


document.getElementByIdx_x("refreshAlarm").src="/public/alarmsum.asp"
mce_src="/public/alarmsum.asp"; //ok


document.frames("refreshAlarm").src="/public/alarmsum.asp"
mce_src="/public/alarmsum.asp"; //没变化,没动静


注意区别,document.all.refreshAlarm 或 document.frames("refreshAlarm")
得到的是information.asp页面中那个iframe标签,所以对src属性操作有用。
document.frames("refreshAlarm").document得到iframe里面的内容,也就是"/public/alarmsum.asp"中的内容。


这里需要补充说明的是:


采用document.getElementByIdx_x获取后reload是不可以的


但是可以这样


var myiframe = document.getElementByIdx_x("iframe1");


myiframe.src = myiframe.src; //这样同样可以起到刷新的效果。



自动刷新页面



javascript(js)自动刷新页面的实现方法总结2008-04-18 13:24
自动刷新页面的实现方法总结:


1)
<meta
http-equiv="refresh"content="10;url=跳转的页面">
10表示间隔10秒刷新一次
2)
<script
language=''javascript''>
window.location.reload(true);
</script>
如果是你要刷新某一个iframe就把window给换成frame的名字或ID号
3)
<script
language=''javascript''>
window.navigate("本页面url");
</script>
4>


function
abc()
{
window.location.href="/blog/window.location.href";
setTimeout("abc()",10000);
}


刷新本页:
Response.Write("<script
language=javascript>window.location.href=window.location.href;</script>")


刷新父页:
Response.Write("<script
language=javascript>opener.location.href=opener.location.href;</script>")


转到指定页:
Response.Write("<script
language=javascript>window.location.href='yourpage.aspx';</script>")



刷新页面实现方式总结(HTML,ASP,JS)
'by aloxy


定时刷新:
1,<script>setTimeout("location.href='url'",2000)</script>


说明:url是要刷新的页面URL地址
2000是等待时间=2秒,


2,<meta name="Refresh" content="n;url">


说明:
n is the number of seconds to wait before loading the specified
URL.
url is an absolute URL to be
loaded.
n,是等待的时间,以秒为单位
url是要刷新的页面URL地址


3,<%response.redirect url%>


说明:一般用一个url参数或者表单传值判断是否发生某个操作,然后利用response.redirect 刷新。


4,刷新框架页
   〈script
language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload();</script〉


弹出窗体后再刷新的问题



Response.Write("<script>window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight:
300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft:
133px')</script>");//open
            
Response.Write("<script>document.location=document.location;</script>");


在子窗体页面代码head中加入<base target="_self"/>


刷新的内容加在    if (!IsPostBack) 中


在框架页中右面刷新左面
    //刷新框架页左半部分
    Response.Write("<script
language=javascript>");
   
Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'");
   
Response.Write("</script>");



页面定时刷新功能实现


有三种方法:
1,在html中设置:
<title>xxxxx</title>之後加入下面这一行即可!
定时刷新:<META
HTTP-EQUIV="Refresh" content="10">
10代表刷新间隔,单位为秒


2.jsp
<% response.setHeader("refresh","1"); %>
每一秒刷新一次


3.使用javascript:
<script
language="javascript">
setTimeout("self.location.reload();",1000);
<script>
一秒一次



页面自动跳转:
1,在html中设置:
<title>xxxxx</title>之後加入下面这一行即可!
定时跳转并刷新:<meta
http-equiv="refresh"
content="20;url=http://自己的URL">,
其中20指隔20秒后跳转到http://自己的URL 页面。



点击按钮提交表单后刷新上级窗口


A窗口打开B窗口


然后在B里面提交数据至C窗口


最后要刷新A窗口


并且关闭B窗口


几个javascript函数


//第一个自动关闭窗口
<script language="javascript">
<!--
function
clock(){i=i-1
document.title="本窗口将在"+i+"秒后自动关闭!";
if(i>0)setTimeout("clock();",1000);
else
self.close();}
var i=2
clock();
//-->
</script>


//第二个刷新父页面的函数


<script
language="javascript">
opener.location.reload();
</script>



//第三个打开窗口


<script language="javascript">
function
show(mylink,mytitle,width,height)
{mailwin=window.open(mylink,mytitle,'top=350,left=460,width='+width+',height='+height+',scrollbars=no')}
</script>

posted @ 2013-06-02 21:39 一堣而安 阅读(636) | 评论 (0)编辑 收藏

java正则表达式 提取、替换(转)

     摘要: java正则表达式 提取、替换事例1http://www.cnblogs.com/lihuiyy/archive/2012/10/08/2715138.html比如,现在有一个 endlist.txt 文本文件,内容如下:1300102,北京市1300103,北京市1300104,北京市1300105,北京市1300106,北京市1300107,北京市1300108,北京市1300109,北京市1...  阅读全文

posted @ 2013-05-31 20:26 一堣而安 阅读(3013) | 评论 (0)编辑 收藏

oracle的nvl和sql server的isnull (转)

http://www.cnblogs.com/sunyjie/archive/2012/03/26/2417688.html

最近公司在做Oracle数据库相关产品,在这里作以小结:

ISNULL()函数

语法   
ISNULL ( check_expression , replacement_value)   
参数
   check_expression   
   将被检查是否为    NULL的表达式。check_expression    可以是任何类型的。   
   replacement_value   
   在    check_expression    为    NULL时将返回的表达式。replacement_value    必须与    check_expresssion    具有相同的类型。     
返回类型
   返回与    check_expression    相同的类型。   
注释
   如果    check_expression    不为    NULL,那么返回该表达式的值;否则返回    replacement_value。

----------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------

nvl( ) 函数

从两个表达式返回一个非 null 值。  
语法
NVL(eExpression1, eExpression2)   
参数
eExpression1, eExpression2   
如果 eExpression1 的计算结果为 null 值,则 NVL( ) 返回 eExpression2。如果 eExpression1 的计算结果不是 null 值,则返回 eExpression1。eExpression1 和 eExpression2 可以是任意一种数据类型。如果 eExpression1 与 eExpression2 的结果皆为 null 值,则 NVL( ) 返回 .NULL.。   
返回值类型
字符型、日期型、日期时间型、数值型、货币型、逻辑型或 null 值   
说明
在不支持 null 值或 null 值无关紧要的情况下,可以使用 NVL( ) 来移去计算或操作中的 null 值。

select nvl(a.name,'空得') as name from student a join school b on a.ID=b.ID

注意:两个参数得类型要匹配

posted @ 2013-05-20 20:47 一堣而安 阅读(263) | 评论 (0)编辑 收藏

介绍概要设计和详细设计该写成什么程度(转)

http://wenku.baidu.com/view/78ed49eae009581b6bd9ebae.html

posted @ 2013-05-07 17:18 一堣而安 阅读(221) | 评论 (0)编辑 收藏

仅列出标题
共17页: First 上一页 6 7 8 9 10 11 12 13 14 下一页 Last 

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

收藏夹

搜索

最新评论

阅读排行榜

评论排行榜