久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

簡單的flex 2 mysql jsp實(shí)例

 WindySky 2007-04-26

看了網(wǎng)上一文《貼個Flex-Jsp-Mysql簡單結(jié)合例子》,,作為練習(xí),,改為flex2.0環(huán)境下運(yùn)行。
1,、請先設(shè)置好flex運(yùn)行的環(huán)境,,參考《flex2環(huán)境簡單配置》并在mysql數(shù)據(jù)庫中創(chuàng)建數(shù)據(jù)庫web,可用下載文件中的tblmobile.sql導(dǎo)入數(shù)據(jù),表結(jié)構(gòu)為:

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)
);

2、將getmysql.mxml和t.jsp復(fù)制到你的應(yīng)用程序的根目錄下,,比如e:\tomcat 5.5\webapps\flex,將mysql數(shù)據(jù)庫的驅(qū)動程序mysql-connector-java-5.0.3-bin.jar放入e:\tomcat 5.5\webapps\flex\WEB-INF\lib下,,重啟tomcat,下面是效果:

3、getmysql.mxml發(fā)送請求并顯示返回的數(shù)據(jù)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="   <mx:HTTPService id="userRequest" url="      <mx:request xmlns="">
         <categoryID>{cid.text}</categoryID>
      </mx:request>
   </mx:HTTPService>
   <mx:Form x="22" y="10" width="493">
      <mx:HBox>
         <mx:Label text="categoryID"/>
         <mx:TextInput id="cid" />
      </mx:HBox>
      <mx:Button label="Submit" click="userRequest.send()"/>
   </mx:Form>
   <mx:DataGrid id="dgUserRequest" x="22" y="100" dataProvider="{userRequest.lastResult.phonelist.phone}">
      <mx:columns>
         <mx:DataGridColumn headerText="ID" dataField="id"/>
         <mx:DataGridColumn headerText="User Name" dataField="name"/>
         <mx:DataGridColumn headerText="Images" dataField="image"/>

      </mx:columns>
   </mx:DataGrid>
</mx:Application>

4,、t.jsp處理請求并發(fā)送xml格式的數(shù)據(jù)

<?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");
    if(categoryID==null) categoryID="1";

    try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        url = "jdbc:mysql://localhost/web?user=root&password=&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>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn),。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多