ITeye博客

Xue_zhang的博客

Xue_zhang · 共 13 篇文章

[置顶] java基础 ——十六进制的转换二

class ToHex1 { public static void main(String args) { toHex2(60); } public static void toHex2(int num){ char arr={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; char ar=new char; int pos=ar.length; while(num!=0){ int temp = num & 15; ar=arr; num = num>>>4; } for(int x= pos ;x<ar.…

2011-08-30 18:26 · java基础 · 评论(0)

extjs4 Ext.util.Format类的使用

Ext.onReady(function(){ Ext.Msg.alert("提示","Ext.util.Format用法"); var teststr = "dasfhasjfhj" var teststr2 = "DAFGDfsy"; //capitalize将首字符串的第一个字母大写 var capitalizeResult = Ext.util.Format.capitalize(teststr); alert("capitalize()方法的功能:将首字符串的第一个字母大写"+capitalizeResult); //capitalize()方法的功能:如果testStr的长度大于…

2012-11-26 13:27 · extjs4 · 评论(0)

String 常见功能

1 获取: 1.1 字符串中包含的字符数,也就是字符的长度 int length(); 1.2 根据位置获取位置上某个字符 char charAt(int index); 1.3 根据字符获取该字符在字符串上的位置 int indexOf(int ch);返回的是ch在字符串上第一次出现的位置 2 判断 2.1 字符串中是否包含某一个子串 boolean contains(str); 特殊之处:indexOf(str) 可以索引str第一次出现的位置,如果返回-1,表示该str不存在字符串中。 所以,也可以用于对制定判断是否包含。 if(str.indexOf(str)!=-1); 而且该方…

2011-09-25 13:01 · java基础 · 评论(0)

java基础 ——十六进制的转换一

class ToHex { public static void main(String args) { toHex1(60); } public static void toHex1(int num){ StringBuffer sb= new StringBuffer(); for(int x=0;x<8;x++){ int temp=num&15; if(temp>9){ //System.out.println((char)(temp-10+'A')); sb.append((char)(temp-10+'A')); }else{ //System.out.println(temp)…

2011-08-30 16:59 · java基础 · 评论(0)

java基础 ——数组折半查找

class BinarySearch { public static void main(String args) { int arr={1,2,3,4,5,6,7,}; int temp=search(arr,2); System.out.println(temp); } // 折半查找前提是:数组必须是有序的 public static int search(int arr,int key){ int min,max,mid; min=0; max=arr.length-1; mid=(min+max)/2; while(arr!=key){ if(arr<key){ min=mid+1…

2011-08-30 14:49 · java基础 · 评论(0)

java基础——数组中的查找

class Found{ public static void main(String args){ int arr={1,2,3,4,5,6,7}; int temp=found(arr,43); if(temp==-1){ System.out.println("没有该数据"); } else{ System.out.println(temp); } } //获取key值第一次出现在数组中的位置 public static int found(int arr,int key){ for(int x=0;x<arr.length;x++){ if(arr==key) return x; }…

2011-08-30 14:25 · java基础 · 评论(0)

java基础 ——冒泡排序

class SelectSort{ public static void main(String args){ int arr={1,22,9,12,5,6,7}; bubble(arr); for(int x=0;x<arr.length;x++){ System.out.println(arr); } } //冒泡排序 public static void bubble(int arr){ for(int x=0;x<arr.length;x++){ for(int y=0;y<arr.length-x-1;y++){ if(arr>arr){ int temp=arr; arr=arr…

2011-08-30 14:06 · java基础 · 评论(0)

java基础 ——选择排序

class SelectSort{ public static void main(String args){ int arr={1,22,9,12,5,6,7}; select(arr); for(int x=0;x<arr.length;x++){ System.out.println(arr); } } //选择排序 public static void select(int arr){ for(int x=0;x<arr.length-1;x++){ for(int y = x+1;y<arr.length;y++){ if(arr>arr){ int temp=arr; arr=a…

2011-08-30 14:05 · java基础 · 评论(0)

struts2 select标签的用法

struts2 select标签的用法 struts2的select标签中,常用的有以下几个属性: (1)struts2中的select 标签中,必须设置的属性只有一个,即是list。 (2)select标签的list中必须有值,不然会报错。如果没有值,可以加上headerKey, headerValue,这样就可以通过了。如: xml 代码<s:select name="geElement.childType" list="childTypeList" listKey="key" listValue="value" headerKey="0" headerValue="--请选择子类型--…

2011-06-19 15:42 · struts2 · 评论(0)

struts2注册xml验证

使用xml文件完成属性的验证 一共有六个字段(也就是表单的六个属性).分别是 username ,password ,repassword ,age,birthday,graduation ..要求是 每个属性不能为空,前面三个必须在6到10个字符之间.年龄在1到150之间.birthday 为2001-01-01到2003-12-31之间,graduation在2005-01-01与2007-12-31之间..这些就是我们这节要实现的需求.. 当然,还有其他需求,比如password与repassword必须相等,还有bithday必须在graduation之前. 配置xml文件.放在ac…

2011-06-14 02:26 · struts2 · 评论(0)

ssh配置文件

web.xml <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:beans.xml</param-value> </context-param> <!-- 对Spring容器进行实例化 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>struts2<…

2011-06-12 11:42 · 评论(0)

使用Hibernate进行分页的实现

使用Hibernate进行分页的实现 某个类---映射的表进行实现分页技术 查询的表的记录过程————————只是获取当前页的信息 首页:0-----4 当前页: 上一页:当前页-1 下一页:当前页+1 最后一页:末页 每页显示的记录数是多少呢? 5 查询当前页的信息 ------------------------------------- 当前页在表中的起始位置及结束位置. 递增序列 姓名 起始位置: 1 0 2 3 4 6 8 100 101 102 103 104 200 比如在这里: //每页显示记录数 private Integer pagesize=5; //定义当前页变量 p…

2011-06-09 11:48 · hibernate · 评论(0)

struts2文件上传

1 public String upload() { FileInputStream fis = null; FileOutputStream fos = null; String savePath = getSavepath(); File file = new File(savePath); if (!file.exists()) { file.mkdirs(); } try { fis = new FileInputStream(pic); fos = new FileOutputStream(file+"//"+getPicFileName()); byte b = new byte…

2011-06-08 15:01 · struts2 · 评论(0)