- 博客(109)
- 问答 (11)
- 收藏
- 关注
原创 AJAX中URL的参数带中文
package action;import java.io.UnsupportedEncodingException;import java.net.URLDecoder;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.ServletActionContext;impo...
2012-07-06 20:04:30
531
原创 为textfield添加验证
这块的代码是用struts2的UI标签写的,用jquery验证我还没有找到方法,就只能通过事件触发来添加验证了。要求Requisition ID必须是数字的。 <tr> <td style="width: 100px"><span>Region</span></td> <td>
2011-10-13 13:35:07
315
原创 Effective java 第三条
用私有构造器或者枚举类型强化Singleton属性。 两种方法:第一种:public class Elvis{ public static final Elvis = new Elvis(); private Elvis() {} public void leaveTheBuilding(){ }...
2011-10-11 21:08:19
252
原创 Effective java 第二条
遇到多个构造器参数时要考虑用构建器。 package Builder;public class Student { private final String name; private final int id; private final String sex; private final String birth; private final Strin...
2011-10-10 21:08:07
235
原创 Effective java 第一条
第一条.考虑用静态工厂方法代替构造器! 优势:1.有名称。BigInteger的probablePrime方法。public static BigInteger probablePrime(int bitLength, Random rnd) { if (bitLength < 2) throw new ArithmeticException("bitLength <...
2011-10-09 21:56:42
239
原创 路径问题
看马士兵老师的Struts2总结,觉得这个方法很好。 <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> ...
2011-10-07 19:33:21
112
原创 Struts2 HelloWorld之后干点实事吧!
呵呵~一鼓作气!再弄点!HelloWorld不能一直下去吧!HelloWorld里的struts.xml很简单。 <package name="default" extends="struts-default"> <action name="hello"> <result > ..
2011-10-06 23:41:09
108
原创 迈出Struts2的第一步
开始实习啦!主要从事Web应用开发!目前就是ERP项目的重构~压力很大啊!虽然以前做的项目都是用Java写的,但是Web方面没有怎么接触,也就对Servlet有点了解~没办法啦!Struts2必须得会啊~ 一步一步慢慢来吧!开始我的Struts之旅了! 万物都是HelloWorld! 先构建好项目的框架吧!至少得跑起来! IED...
2011-10-06 23:11:01
153
原创 SQL Server数据库中选出指定范围行的SQL语句
我们今天主要和大家一起分享的是SQL Server数据库中选出指定范围行的一些SQL语句的正确写法,如果我们按照通常的方法是实现不了的,我们得借助于临时表以及在数据库查询的时候,我们有时有这样的需求,就是要找出数据表里指定范围行内的数据记录。比如说要找出数据表里第10行到第20行的这10条数据,那么我们怎么来实现呢?按照通常的方法是实现不了的,我们得借助于临时表以及一个函数来实现代码如...
2011-09-24 16:24:14
1257
原创 在字符串中删除特定的字符
题目:输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。例如,输入”They are students.”和”aeiou”,则删除之后的第一个字符串变成”Thy rstdnts.”。 其实这类题有个特点,字符串中的字符分为两类,就可以联想快速排序里的将当前的数组分为左右两组,其中左边的数字小于某值,右边的数字大于某值。这种大于和小于就是将分为两类。当然,等于也是,但是可以忽略。...
2011-09-19 20:19:51
282
原创 输入一个正数n,输出所有和为n 连续正数序列
题目:输入一个正数n,输出所有和为n 连续正数序列。例如输入15,由于1+2+3+4+5=4+5+6=7+8=15,所以输出3 个连续序列1-5、4-6 和7-8。 思路:就简单的方法就是两重循环,算这两个标志之间的和! 代码:public static int sum(int begin, int end) { return ((end - begin +...
2011-09-18 10:11:48
892
原创 面试题
打印如下图案**。*。。*。。*。。。*。。。*。。。*。。。。*。。。。*。。。。*。。。。*。。。。。*。。。。。*。。。。。*。。。。。*。。。。。*。。。。。。*。。。。。。*。。。。。。*。。。。。。*。。。。。。*。。。。。。*。。。。。。。*。。。。。。。*。。。。。。。*。。。。。。。*。。。。。。。*。。。。。。。 三重循环肯定没问题。但是觉得二重也可以! ...
2011-09-17 14:41:40
140
原创 (中兴笔试题)求一个字符串中的最长子串
今天参加了中兴的笔试题,感觉不是很难!还好吧!就是聊的时候觉得自己的表达能力不是很好!需要锻炼啊! public static String find(String str){ if(str.equals("")){ return ""; }else{ int maxLen = 0; int curLen = 0; String maxS...
2011-09-17 14:14:33
165
原创 输入两个整数 n 和 m,从数列1,2,3.......n 中 随意取几个数,
题目:输入两个整数 n 和 m,从数列1,2,3.......n 中 随意取几个数,使其和等于 m ,要求将其中所有的可能组合列出来.代码: public static int count = 0; public static void traverse(int number, int sum, Stack stack) { for (int i = numbe...
2011-09-16 15:04:00
213
原创 栈的push和pop判断
题目:题目:输入两个整数序列。其中一个序列表示栈的push顺序,判断另一个序列有没有可能是对应的pop顺序。为了简单起见,我们假设push序列的任意两个整数都是不相等的。 比如输入的push序列是1、2、3、4、5,那么4、5、3、2、1就有可能是一个pop系列。因为可以有如下的push和pop序列:push 1,push 2,push 3,push 4,pop,push 5,pop...
2011-09-15 18:49:02
676
原创 详解java中的抽象类和接口的区别
在Java语言中, abstract class 和interface 是支持抽象类定义的两种机制。正是由于这两种机制的存在,才赋予了Java强大的 面向对象能力。abstract class和interface之间在对于抽象类定义的支持方面具有很大的相似性,甚至可以相互替换,因此很多开发者在进 行抽象类定义时对于abstract class和interface的选择显得比较随意。其实,两者之间还...
2011-09-15 15:09:49
106
原创 在二元树中找出和为某一值的所有路径
题目: 题目:输入一个整数和一棵二元树。从树的根结点开始往下访问一直到叶结点所经过的所有结点形成一条路径。打印出和与输入整数相等的所有路径。例如 输入整数22和如下二元树 10 / \ 5 12 / \ 4 7则打印出两条路径:10, 12和10, 5, 7。思路:有两种方法,递归和非递归。其中非递归使用前序遍历,一条路走到底,并且每次访问一个节点...
2011-09-14 20:25:03
118
原创 判断整数序列是不是二元查找树的后序遍历结果
问题描述:判断整数序列是不是二元查找树的后序遍历结果题目:输入一个整数数组,判断该数组是不是某二元查找树的后序遍历的结果。如果是返回true,否则返回false。例如输入5、7、6、9、11、10、8,由于这一整数序列是如下树的后序遍历结果: 8 / \ 6 10 / \ / \ 5 7 9 11因此返回true。如果输入7、4、6、5,没有哪棵树的后序遍历的结果是这个序列,因此返回...
2011-09-13 18:47:06
127
原创 把二元查找树转变成排序的双向链表
题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点,只调整指针的指向。 10 / \ 6 14 / \ / \4 8 12 16 转换成双向链表4=6=8=10=12=14=16。 中序遍历,遍历的过程生成双向链表。 先实现双线链表,然后实现二叉查找树。 class Node { private int val...
2011-09-11 20:08:58
119
原创 寻找丢失的数字
据传说是MS/Google等等IT名企业的面试题:有一组数字,从1到n,中减少了一个数,顺序也被打乱,放在一个n-1的数组里请找出丢失的数字,最好能有程序,最好算法比较快 假如有1,2,3,···,10十个数字,并且少了5,那么遍历数组求和得到50,在遍历的过程中得知最大数字为10,那么如果不少5,全部数字和为55,则缺少的数字为55-50=5如果少了10,那么遍历数组得到...
2011-09-08 14:28:25
312
原创 Problem 52
问题描述:It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, an...
2011-09-07 19:37:20
122
原创 Problem 51
问题描述: By replacing the 1st digit of *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.By replacing the 3rd and 4th digits of 56**3 wit...
2011-09-06 19:46:26
121
原创 【转载】VC++对象模型
前言 了解你所使用的编程语言究竟是如何实现的,对于C++程序员可能特别有意义。首先,它可以去除我们对于所使用语言的神秘感,使我们不至于对于编译器干的 活感到完全不可思议;尤其重要的是,它使我们在Debug和使用语言高级特性的时候,有更多的把握。当需要提高代码效率的时候,这些知识也能够很好地帮助 我们。 本文着重回答这样一些问题: * 类如何布局? * 成员...
2011-09-06 18:15:50
90
原创 【转载】面向对象三要素
面向对象三要素是封装 继承 多态 封装 封装就是事物抽象为类,把对外接口暴露,将实现和内部数据隐藏。继承面向对象编程 (OOP) 语言的一个主要功能就是“继承”。继承是指这样一种能力:它可以使用现有类的所有功能,并在无需重新编写原来的类的情况下对这些功能进行扩展。通过继承创建的新类称为“子类”或“派生类”。被继承的类称为“基类”、“父类”或“超类”...
2011-09-06 18:14:27
129
原创 Problem 50
问题描述: The prime 41, can be written as the sum of six consecutive primes:41 = 2 + 3 + 5 + 7 + 11 + 13This is the longest sum of consecutive primes that adds to a prime below one-hundred.The...
2011-09-03 14:53:46
179
原创 Problem 49
问题描述: The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbe...
2011-08-28 15:34:22
146
原创 Problem 47
问题描述: The first two consecutive numbers to have two distinct prime factors are:14 = 2 715 = 3 5The first three consecutive numbers to have three distinct prime factors are:644 = 2² 7...
2011-08-27 16:10:21
133
原创 Problem 46
问题描述:It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.9 = 7 + 21215 = 7 + 22221 = 3 + 23225 = 7 + 23227 = 19 + 22233 ...
2011-08-26 18:08:58
146
原创 <分享>JNDI全攻略
JNDI全攻略之(一)关键字:JNDI,J2EE,Java,命名和目录接口,Java Naming and Directory Interface摘要:本文详细介绍了JNDI的架构与实现,JNDI的工作原理,并给出了具体代码,帮助读者更理解J2EE主要常用技术---JNDI.本文为系列文章的第一篇,其它相关文章会在近期推出。 名词解释 jndi是Java 命...
2011-08-25 18:25:48
218
原创 Problem 45
问题描述: Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ...Pentagonal Pn=n(3n1)/2 1, 5, 12, 22, 35...
2011-08-25 18:24:11
102
原创 Problem43
问题描述:The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property....
2011-08-24 16:32:49
190
原创 Problem 42
问题描述:The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are:1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...By converting each letter in a wo...
2011-08-23 09:18:57
109
原创 Problem 41
问题描述:We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.What is the largest n-di...
2011-08-19 15:08:12
121
原创 Problem 40
算法描述:An irrational decimal fraction is created by concatenating the positive integers:0.123456789101112131415161718192021...It can be seen that the 12th digit of the fractional part is 1.If ...
2011-08-18 14:27:19
129
原创 Problem 39
问题描述:If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.{20,48,52}, {24,45,51}, {30,40,50}For which value of p ...
2011-08-17 15:28:08
113
原创 Problem 38
问题描述:Take the number 192 and multiply it by each of 1, 2, and 3:192 * 1 = 192192 * 2 = 384192 * 3 = 576By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 19238...
2011-08-17 15:27:17
107
原创 Problem 37
问题描述:The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similar...
2011-08-17 15:26:00
141
原创 Problem 36
问题描述:The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.(Please note t...
2011-08-17 15:23:48
96
原创 Problem 35
问题描述:The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31...
2011-08-17 15:22:28
124
原创 Problem 34
问题描述:145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.Find the sum of all numbers which are equal to the sum of the factorial of their digits.Note: as 1! = 1 and 2! = 2 are not su...
2011-08-17 15:20:17
92
空空如也
关于web开发中使用tomcat,启动一个线程
2012-05-04
一个生产者和多个消费者的互斥问题
2012-04-25
关于ehcache处理大数据的问题
2012-04-20
关于Mina中服务器给客户端发送数据的问题
2012-04-11
找一个JQuery的控件
2011-10-21
多重for循环的continue问题
2011-08-28
关于Hadoop的java_home配置的问题
2011-05-03
非阻塞通信的问题
2011-03-26
关于JTree的生成问题
2011-03-04
是用DOM解析xml的问题
2011-03-03
ftpclient的中文字符显示问题
2011-01-19
TA创建的收藏夹 TA关注的收藏夹
TA关注的人