<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    flex2 + jsp +mysql sample

    數據庫表
    這個sql是用pd生成的,具體內容大家自己看一下好了,很簡單,數據也自己填充一下。標題上說是用mysql,其實無所謂用啥數據庫了,這里我推薦Postgresql,現在有for win平臺了,不用cygwin來模擬unix環境,這個Postgresql一來小巧,二來功能齊全,看起來有點象Oracle,當然速度也很快了。

    /* ============================================================== */
    /* ?Table:?tblmobile????????????????????????????????????????????? */
    /* ============================================================== */
    create ? table ?tblmobile
    (
    ???id?????????????????????????????
    integer ( 11 )???????????????????? not ? null ? default ? 0
    ,
    ???categoryid?????????????????????
    integer ( 11
    ),
    ???name???????????????????????????
    varchar ( 255
    ),
    ???
    image ?????????????????????????? varchar ( 255
    ),
    ???price??????????????????????????
    decimal ( 12 , 2
    ),
    ???addtime????????????????????????
    datetime
    ,
    ???
    primary ? key
    ?(id)
    );

    /* ============================================================== */

    /* ?Index:?i_tblMobile_categoryid???????????????????????????????? */
    /* ============================================================== */
    create ? index ?i_tblMobile_categoryid? on ?tblmobile
    (
    ???categoryid
    );

    /* ============================================================== */

    /* ?Index:?pk_tblmobile?????????????????????????????????????????? */
    /* ============================================================== */
    create ? unique ? index ?pk_tblmobile? on ?tblmobile
    (
    ???id
    );

    /* ============================================================== */

    /* ?Index:?i_tblmobile_addtime??????????????????????????????????? */
    /* ============================================================== */
    create ? index ?i_tblmobile_addtime? on ?tblmobile
    (
    ???addtime
    );


    phonselist.jsp
    Jsp服務器用的是Tomcat,順便做flex的服務器,版本沒啥大關系,我現在用的是5.0.28,Jsp功能是按手機分類id從mysql數據庫獲取手機列表,這里為方便起見直接在jsp頁面里進行數據庫訪問,正確的做法應該由javabean來分工,其后總jsp生成的是一個xml文件。
    <?xml?version="1.0"?encoding="utf-8"?>
    <%@?page?contentType="text/html;charset=utf-8"%>
    <%@?page?import="java.sql.*"%>
    <phonelist>
    <%
    ????
    String?sql?=?"";
    ????
    String?url?=?"";

    ????
    String?categoryID?=?request.getParameter("categoryID");

    ????
    try?{
    ????????
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    ????????url?
    =?"jdbc:mysql://localhost/web?user=flex&password=flex&useUnicode=true&characterEncoding=gb2312";
    ????????Connection?conn?
    =?DriverManager.getConnection(url);
    ????????Statement?stmt?
    =?conn.createStatement();

    ????????sql?
    =?"select?id,?name,?price,?image?from?tblMobile?where?categoryid="?+?categoryID;
    ????????ResultSet?rs?
    =?stmt.executeQuery(sql);

    ????????
    while?(rs.next()){
    ????????????out.println(
    "<phone?id=\""?+?rs.getString(1)?+?"\">");
    ????????????out.println(
    "<id>"?+?rs.getString(1)?+?"</id>");
    ????????????out.println(
    "<name>"?+?rs.getString(2)?+?"</name>");
    ????????????out.println(
    "<price>"?+?rs.getString(3)?+?"</price>");
    ????????????out.println(
    "<image>"?+?rs.getString(4)?+?"</image>");
    ????????????out.println(
    "</phone>");
    ????????}

    ????????rs.close();
    ????????stmt.close();
    ????????conn.close();

    ????}?
    catch?(Exception?e)?{
    ????????out.println(e);
    ????}
    %
    >
    </phonelist>

    mobile.mxml
    這里要注意一下<mx:HTTPService>中的resultFormat="xml"的設置,在這里應該把這個取掉(我原來是用來做Tree用的)。phonelisg.jsp和mobile.mxml放在相同的目錄下,當然你也可以修改url的路徑。
    <?xml?version="1.0"?encoding="utf-8"?>

    <mx:Application?xmlns:mx="http://www.macromedia.com/2003/mxml"
    ????verticalGap
    ="10"
    ????backgroundColor
    ="#FFFFFF"
    ????pageTitle
    ="手機"
    ????initialize
    ="initApp()">
    ????
    ????
    <mx:Style?source="main.css"/>

    ????
    <mx:HTTPService?id="phoneService"?url="phonelist.jsp"?resultFormat="xml">
    ????????
    <mx:request>
    ????????????
    <categoryID>{categoryId}</categoryID>
    ????????
    </mx:request>
    ????
    </mx:HTTPService>

    ????
    <mx:Model?id="phonelist">
    ????????{phoneService.result.phonelist.phone}
    ????
    </mx:Model>


    ????
    <mx:Script>
    ????????
    <![CDATA[

    ????????var?categoryId?=?2;
    ????????var?categoryName?=?"Moto";
    ????
    ????????function?initApp()?{
    ????????????phoneService.send();
    ????????}

    ????????
    ]]>
    ????
    </mx:Script>

    ????
    <mx:HBox>
    ????????
    <mx:LinkBar?styleName="title"?width="500"?click=""?>
    ????????????
    <mx:dataProvider>
    ????????????????
    <mx:Array>
    ????????????????????
    <mx:Object?label="首?頁"?link="main"/>
    ????????????????????
    <mx:Object?label="手機分類"?link="catagory"/>
    ????????????????????
    <mx:Object?label="論?壇"?link="forum"/>
    ????????????????????
    <mx:Object?label="關?于"?link="about"/>
    ????????????????
    </mx:Array>
    ????????????
    </mx:dataProvider>
    ????????
    </mx:LinkBar>
    ????????
    <mx:Label?text="搜索"/>
    ????????
    <mx:TextInput?id="key"?width="120"/>
    ????????
    <mx:Button?label="Go"/>
    ????
    </mx:HBox>
    ????
    ????
    <mx:HBox>
    ????????
    <mx:Image?source="images/qd_2.jpg"/>
    ????????
    <mx:Label?id="debug"?text="123"/>
    ????
    </mx:HBox>

    ????
    <mx:Effect>
    ????????
    <mx:Zoom?name="zoomBig"?zoomTo="107"?duration="100"/>
    ????????
    <mx:Zoom?name="zoomSmall"?zoomTo="100"?duration="100"/>
    ????
    </mx:Effect>

    ????
    <mx:HBox>
    ????????
    <mx:Panel?id="main"?title=""?height="360">????????????
    ????????????????
    <mx:Tile?width="520">
    ????????????????????
    <mx:Repeater?id="plist"?dataProvider="{phonelist}"?startingIndex=""?count="">
    ????????????????????????
    <mx:VBox?id="itemBox"?verticalGap="0"?horizontalAlign="center"?mouseUp="">
    ????????????????????????????
    <mx:Canvas?width="100"?height="100"?clipContent="false">
    ????????????????????????????????
    <mx:Image?width="90"?height="90"?source="{plist.currentItem.image}"?toolTip="RMB?{plist.currentItem.price}"?mouseOverEffect="zoomBig"?mouseOutEffect="zoomSmall"?visible="false"?complete="event.target.visible=true;"/>
    ????????????????????????????
    </mx:Canvas>
    ????????????????????????????
    <mx:Label?id="itemName"?text="{plist.currentItem.name}"/>
    ????????????????????????????
    <mx:Label?id="itemPrice"?text="RMB{plist.currentItem.price}"/>
    ????????????????????????
    </mx:VBox>
    ????????????????????
    </mx:Repeater>
    ????????????????
    </mx:Tile>
    ????????????
    <mx:ControlBar>
    ????????????????
    <mx:Button?label="上一頁"?click=""/>
    ????????????????
    <mx:Button?label="下一頁"?click=""/>
    ????????????????
    <mx:Button?label="refresh"?click="initApp()"/>
    ????????????
    </mx:ControlBar>
    ????????
    </mx:Panel>
    ????
    </mx:HBox>


    ????
    <mx:HBox?horizontalAlign="center">
    ????????
    <mx:Label?text="Copy?Right?2004??dannyr's?Studio?"/>
    ????
    </mx:HBox>
    </mx:Application>

    ?

    最后:配置Flex服務器
    flex-config.xml

    <http-service-proxy>??
    ????
    <whitelist>?
    ????????????
    <unnamed>????????????
    ????????????????
    <url>http://{localserver}/flex/phonelist.jsp</url>
    ????????????
    </unnamed>
    ????
    </whitelist>
    ?????????
    ??????
    </http-service-proxy>

    posted on 2006-11-27 16:58 leoli 閱讀(548) 評論(0)  編輯  收藏 所屬分類: Flex

    導航

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    統計

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案(17)

    文章分類(86)

    收藏夾(3)

    flex blog

    good site

    java blog

    my friend

    tools

    抓蝦

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 一级成人毛片免费观看| 99999久久久久久亚洲| 亚洲一级毛片在线观| 97人妻无码一区二区精品免费| 亚洲人成网址在线观看| 日本高清免费观看| 亚洲精品资源在线| 日韩在线免费电影| A级毛片成人网站免费看| 亚洲情综合五月天| 永久免费av无码网站韩国毛片 | 亚洲自偷自偷在线成人网站传媒| 成人免费毛片视频| 三年片免费高清版| 亚洲码和欧洲码一码二码三码| 亚洲日韩精品A∨片无码| 免费在线观看黄色毛片| 免费专区丝袜脚调教视频| 一级免费黄色大片| 国产福利在线观看永久免费| 亚洲成aⅴ人在线观看| 亚洲高清最新av网站| 成人免费在线看片| 午夜时刻免费入口| 1000部拍拍拍18勿入免费凤凰福利| 免费无码成人AV在线播放不卡| 九九综合VA免费看| 久久福利青草精品资源站免费| 亚洲妇女无套内射精| 亚洲国产综合第一精品小说| 国产AV旡码专区亚洲AV苍井空 | 91香蕉国产线在线观看免费 | 国产亚洲老熟女视频| 免费一级黄色毛片| 亚洲精品影院久久久久久| 亚洲小说图区综合在线| 国产激情久久久久影院老熟女免费| 免费在线看污视频| 九月婷婷亚洲综合在线| 亚洲一级黄色视频| 亚洲精品无码成人片久久|