作者TonyQ (骨头)
看板java
标题Re: [JSP ] 请问如何将搜寻与javaBean共同使用??
时间Mon Apr 2 20:02:11 2007
※ 引述《longlyheart (longlyheart)》之铭言:
: 抱歉我说不清楚,我最主要的问题是在那个while回圈
: 因为搜寻出来的东西会有很多个,如果我用Bean的话会只接收到最後一个
: 所以只好写在网页里,请问要怎麽写才能接收到"全部"的资料??
: 不过还是谢谢大大,我又多懂了一些~^^~
我是瞎猜的,不过我想唯一的可能性应该也只有这个。
你的SQL中有一个叫 dbname的 parameter,
你的JavaBean应该写成一个method去接收它。
比方说
public String doSearch(String dbName){
StringBuffer output=new StringBuffer();
/* do connection */
String comSQL = "SELECT * FROM articledb WHERE articlename
like'%"+dbname+"
while( /* expression */ ){
/* do something */
output.append( /* HTML tag with data */);
}
..............
return output.toString();
}
如果说只会接收到最後一个,这句话带来的讯息是资料库的查询有正确运作,
你的除错方向就可以朝资料来源和SQL叙述去下手。
--
btw 别让人回答A 後才跟别人说你的问题是B,会让人觉得像在整人。
--
String temp="relax"; | Life just like programing
while(buringlife) String.forgot(temp); | to be right or wrong
while(sleeping) brain.setMemoryOut(); | need not to say
stack.push(life.running); | the compiler will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.practice()); | Bone
everything
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.134.27.68
※ 编辑: TonyQ 来自: 220.134.27.68 (04/02 20:03)