这数据不是定长的所以不能用数组??????????????????????谁说的???使用该方法可以解决该问题,如果不明白去查java api吧
public String[] split(String regex)
public String[] split(String regex)
解决方案 »
- jsp数值校验问题?
- 自定义标签的问题,求教
- 大家好,我初学java,对很多技术不是很了解,只浅知struts、spring、hibernate、taglib等,看了一些资料,但是不知道应该从和学起,请高
- 求救!!!!!!!!!!1数据库连接问题
- 大家帮忙推荐几个java&jsp的好的论坛(国内的)
- 利用jspsmartupload上载文件,如何判断用户指定的需要上载的文件路径不合法!
- el获取list中的值问题?
- 初学者关于连接池的问题?
- [100分]哪位大侠有jsp/servlet/javabean的编程规范?
- 这样将javascript嵌入到java中为什么有时有响应,有时却没有呢?
- [提问]可更新结果集抛出异常,请大虾帮忙看看,谢谢!
- 高分求解答,问题很简单(500分)
class StringTOkenizerExt extends StringTokenizer
{
private String splitStr=new String();
public StringTOkenizerExt(String str, String delim, boolean returnDelims)
{
super(str,delim,true);
splitStr=delim;
} public String[] getArray()
{
String tempString=new String();
int i=super.countTokens();
for(int j=0;j<i;j++)
{
tempString+=" "+super.nextToken()+" ";
}
StringTokenizer st=new StringTokenizer(tempString,splitStr);
i=st.countTokens();
String[] tempArray=new String[i];
for(int j=0;j<i;j++){
tempArray[j]=st.nextToken().trim();
}
return tempArray;
}
}
String test=request.getParameter("test");StringTokenizer st = new StringTokenizer(test,",",false);
while (st.hasMoreTokens())
{
str.add(st.nextToken());
}
str.add(a);还有你的Vector str=new Vector;后面少了括号。
Vector str=new Vector;
StringTokenizer st=new StringTokenizer(test,",");
while (st.hasMoreTokens())
{
st.nextToken();
}
Vector v=new Vector;
StringTokenizer st=new StringTokenizer(test,",");
while (st.hasMoreTokens())
{
v.add(st.nextToken());
}
String str1 = "ab,cd,,ef,g,,,";
//str1.split(",") = {"ab","cd","","ef","g"};//分隔符为","前后的分隔符会被trim掉,中间的不会
String [] str2 = str1.split(",");//在定义的同时赋了值,OK!
Vector str =new Vector();
int i=0;
StringTokenizer st=new StringTokenizer(studentlist,",",false); while (st.hasMoreTokens())
{
str.add(st.nextToken());
out.print("<br>id="+str.elementAt(i));
-----这里怎么写??
Sql="select id from student where id='"+studentid.trim()+"'";
Resu=Stmt.executeQuery(Sql);
if(Resu.next()) throw new Exception("error nu");
i++;
} //end while
Vector str =new Vector();
int i=0;
StringTokenizer st=new StringTokenizer(studentlist,",",false);
//把传过来的studentid开始剖分
while (st.hasMoreTokens())
{
str.add(st.nextToken());
studentid=(String)str.elementAt(i);
//out.print("<br>studentid="+studentid);
Sql="select id from student where id='"+studentid.trim()+"'";
Resu=Stmt.executeQuery(Sql);
if(Resu.next()) throw new Exception("error!");
i++;
} //end while
String ids = "1,2,3,4,5";
String sqlStr = "select id from student where id in(" + ids + ")";
//sqlStr = "select id from student where id in(1,2,3,4,5)";
Resultset Resu = Stmt.executeQuery(Sql);