2.自己写一个方法,将test中的rep替换为with(不要使用jdk1.4.2自带的replace)。
public static string replace(string test,string rep,string with)4.如何将应用程序打包成JAR文件?
5.servlet如何实现定时操作?如何实现定时访问数据库?
6.写一个文件下载程序,并实现更改下载文件名称。
7.当internet后退时,会出现“警告,该网页已经过期”这是如何实现的?
8.如何读取orecle/mysql数据表中第10到20条记录?
9.数据库中两字符型字段相加,oracle/mysql如何实现?
10.谈谈对tomcat和websphere的认识。
11.structs有什么优缺点?
public static string replace(string test,string rep,string with)4.如何将应用程序打包成JAR文件?
5.servlet如何实现定时操作?如何实现定时访问数据库?
6.写一个文件下载程序,并实现更改下载文件名称。
7.当internet后退时,会出现“警告,该网页已经过期”这是如何实现的?
8.如何读取orecle/mysql数据表中第10到20条记录?
9.数据库中两字符型字段相加,oracle/mysql如何实现?
10.谈谈对tomcat和websphere的认识。
11.structs有什么优缺点?
public class test {
public static String replace(String test,String rep,String with){
String [] str = test.split(rep);
String newstr = "";
for(int i=0;i<str.length;i++){
newstr += str[i]+with;
}
return newstr;
}
public static void main(String[] args) {
String str1 = "helloworldhelloworldhelloworld";
String str2 = "world";
String str3 = "you";
String str = test.replace(str1,str2,str3);
System.out.println(str);
}
}
用jar命令,如果采用IDE的话,IDE中有打包工具,直接打包。
问5:
创建一个监听器,监听时间,到时间就去访问这个servlet。
问7:
应该是cookie失效,通过cookie_setMaxAge();来设置失效时间。
问8:
mysql中直接用select * from table where id>=10 and id<=20
直接实现timer就可以了...
你的算法有2个问题 ···1.当test中有多个rep连续出现的时候,结果里确只用一个with去替换。
2.当test不是以rep结束的时候,结果会有一个with多余。
select * from (select rownum as row_num,
t.* from (你自己的查询语句) t where
rownnum < 数值) where row_num >= 数值;
public static String replace(String test, String rep, String with) {
StringBuffer sb = new StringBuffer();
int bi = 0, ei = 0;
while ((ei = test.indexOf(rep, bi)) > -1) {
sb.append(test.substring(bi,ei));
sb.append(with);
bi = ei + rep.length();
}
sb.append(test.substring(bi));
return sb.toString();
}8.如何读取oracle/mysql数据表中第10到20条记录?
oracle:
select * from country_region where rownum < 20
minus
select * from country_region where rownum < 10
mysql:
select * from table1 limit 10,10;
9.数据库中两字符型字段相加,oracle/mysql如何实现?
oracle: select 'ab'||'cd' from dual;
mysql: select concat('ab','cd');
可能存在id不是按顺序排列,要是人家的id是:1,3,5,7,9.....
可能:select * from table where id>=10 and id<=20
就不能奏效。
mysql里面不是有一个:
select * from table LIMIT 9,11
就是查询第9行后(10行)的11条记录(10-20)。
不晓得大家是什么意见。
{
StringBuffer newStr= new StringBuffer();
int repLen = rep.length();
int i=0;
for(i=0;i<str.length()-repLen;i++)
{
if(str.substring(i,i+repLen).equals(rep))
{
newStr.append(with);
if (repLen>1)
i+=repLen-1;
}
else
{
newStr.append(str.substring(i,i+1));
}
}
newStr.append(str.substring(i,str.length()));
return newStr.toString();
}
{
public static String replace(String test,String rep,String with)
{
StringBuffer str=new StringBuffer();
int fromIndex=0;
int start;
while((start=test.indexOf(rep,fromIndex))!=-1)
{
String s=test.substring(fromIndex,start);
str.append(s);
str.append(with);
fromIndex=start+rep.length();
}
return str.toString();
} public static void main(String[] args)
{
String s1="abchhgdbc";
String s2="bc";
String s3="eee";
System.out.println(replace(s1,s2,s3));
}
}
我看struts的优点和缺点都在于他的taglib