作者PsMonkey (痞子军团团长)
看板java
标题Re: [JSP ] 请问如何将搜寻与javaBean共同使用??
时间Mon Apr 2 20:35:18 2007
※ 引述《longlyheart (longlyheart)》之铭言:
: : 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();
: : }
上面已经给你一种方向了,你引了他的言
至少也给人家一点回音,说说你对他这个解法的看法
真的是... 感觉就是把别人的好心回答直接无视...
至少人家的解法是可解的(漂亮与否就是另话)
: public class connectBean{
: private int atSn;
: private String atName = null;
: private String atSize = null;
: private int atPrice;
: private String atPicture = null;
: private String atNotice = null;
: private String atClass = null;
预设都是 null,以後可以不用打後半段了。
: //资料库控制
: public void setdbControl(String dbname){
: try{
: //建立Statement物件
: stmt = conn.createStatement();
: //执行查询
: comSQL = "SELECT * FROM articledb WHERE articlesn like'%"+dbname+"%';";
: rs = stmt.executeQuery(comSQL);
: //读取资料
: while(rs.next()){
^^^^^^^^^^^^^^^^^ [叹气] 果然不出所料... [炸]
这跟 JavaBean 一点关系也没有
麻烦请先搞清楚上面这段程式码再干麽
([小声] tONYq,你也别一直当好人阿... 怎麽都不对我当好人...)
: atSn = rs.getInt("articlesn");
: atName = rs.getString("articlename");
: atSize = rs.getString("size");
: atPrice = rs.getInt("price");
: atPicture = rs.getString("picture");
: atNotice = rs.getString("notice");
: atClass = rs.getString("class");
: }
: 之前的PO文如果引起大大们的不悦,在此致上十二万分的歉意,请原谅..(磕头)
: 这只Bean我不知道要怎麽改才能让使用的网页收到全部的查询结果,请大大指教
这年头适度引言快要变成一种美德了...
--
侃侃长论鲜窒碍 首页:
http://www.psmonkey.idv.tw
众目睽睽无心颤 Blog:
http://ps-think.blogspot.com
茕居少聊常人事
杀头容易告白难 欢迎参观 Java 版(@ptt.cc) \囧/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.228.193.189