|
<!-- Feedsky FEED发布代码开始 --><!-- FEED自动发现标记开始 -->点击这里使用RSS订阅本Blog:<link title="RSS 2.0" type="application/rss+xml" href="http://feed.feedsky.com/softwave" rel="alternate"><!-- FEED自动发现标记结束 --><script language="javascript"><!-- main_sub="c1s67";more_subs="";--> </script><script language="javascript" src="http://www.feedsky.com/jsout/publishlist_v2.js?burl=softwave&out_html=true"></script><!-- Feedsky FEED发布代码结束 -->
数据库表
这个sql是用pd生成的,具体内容大家自己看一下好了,很简单,数据也自己填充一下。标题上说是用mysql<clk>,其实无所谓用啥数据库了,这里我<nobr id="clickeyekey0" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" oncontextmenu="return false" onmouseout="kwL(event,this)" onmousemove="kwM(0)">推荐</nobr></clk>Postgresql,现在有for win平台了,不用cygwin来模拟unix环境,这个Postgresql一来小巧,二来功能齐全,看起来有点象Oracle,当然速度也很快了。
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*Table:tblmobile*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_7.gifcreatetabletblmobile
http://www.360doc.com/DownloadImg/16915/439483_7.gif(
http://www.360doc.com/DownloadImg/16915/439483_7.gifidinteger(11)notnulldefault0,
http://www.360doc.com/DownloadImg/16915/439483_7.gifcategoryidinteger(11),
http://www.360doc.com/DownloadImg/16915/439483_7.gifnamevarchar(255),
http://www.360doc.com/DownloadImg/16915/439483_7.gifimagevarchar(255),
http://www.360doc.com/DownloadImg/16915/439483_7.gifpricedecimal(12,2),
http://www.360doc.com/DownloadImg/16915/439483_7.gifaddtimedatetime,
http://www.360doc.com/DownloadImg/16915/439483_7.gifprimarykey(id)
http://www.360doc.com/DownloadImg/16915/439483_7.gif);
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*Index:i_tblMobile_categoryid*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_7.gifcreateindexi_tblMobile_categoryidontblmobile
http://www.360doc.com/DownloadImg/16915/439483_7.gif(
http://www.360doc.com/DownloadImg/16915/439483_7.gifcategoryid
http://www.360doc.com/DownloadImg/16915/439483_7.gif);
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*Index:pk_tblmobile*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_7.gifcreateuniqueindexpk_tblmobileontblmobile
http://www.360doc.com/DownloadImg/16915/439483_7.gif(
http://www.360doc.com/DownloadImg/16915/439483_7.gifid
http://www.360doc.com/DownloadImg/16915/439483_7.gif);
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*Index:i_tblmobile_addtime*/
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif/**//*==============================================================*/
http://www.360doc.com/DownloadImg/16915/439483_7.gifcreateindexi_tblmobile_addtimeontblmobile
http://www.360doc.com/DownloadImg/16915/439483_7.gif(
http://www.360doc.com/DownloadImg/16915/439483_7.gifaddtime
http://www.360doc.com/DownloadImg/16915/439483_7.gif);
http://www.360doc.com/DownloadImg/16915/439483_7.gif
phonselist.jsp
Jsp服务器用的是Tomcat,顺便做flex<clk>的服务器,版本没啥大关系,我现在用的是5.0.28,Jsp功能是按<nobr id="clickeyekey2" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" oncontextmenu="return false" onmouseout="kwL(event,this)" onmousemove="kwM(2)">手机</nobr>分类id从</clk>mysql数据库获取手机列表,这里为方便起见直接在jsp页面里进行数据库访问,正确的做法应该由javabean来分工,其后总jsp生成的是一个xml文件。
http://www.360doc.com/DownloadImg/16915/439483_7.gif<?xmlversion="1.0"encoding="utf-8"?>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<%@pagecontentType="text/html;charset=utf-8"%>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<%@pageimport="java.sql.*"%>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<phonelist>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<%
http://www.360doc.com/DownloadImg/16915/439483_7.gifStringsql="";
http://www.360doc.com/DownloadImg/16915/439483_7.gifStringurl="";
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gifStringcategoryID=request.getParameter("categoryID");
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.giftry{
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gifClass.Class.forName("com.mysql.jdbc.Driver").newInstance();
http://www.360doc.com/DownloadImg/16915/439483_64.gifurl="jdbc:mysql://localhost/web?user=flex&password=flex&useUnicode=true&characterEncoding=gb2312";
http://www.360doc.com/DownloadImg/16915/439483_64.gifConnectionconn=DriverManager.getConnection(url);
http://www.360doc.com/DownloadImg/16915/439483_64.gifStatementstmt=conn.createStatement();
http://www.360doc.com/DownloadImg/16915/439483_64.gif
http://www.360doc.com/DownloadImg/16915/439483_64.gifsql="selectid,name,price,imagefromtblMobilewherecategoryid="+categoryID;
http://www.360doc.com/DownloadImg/16915/439483_64.gifResultSetrs=stmt.executeQuery(sql);
http://www.360doc.com/DownloadImg/16915/439483_64.gif
http://www.360doc.com/DownloadImg/16915/439483_64.gifwhile(rs.next()){
http://www.360doc.com/DownloadImg/16915/439483_64.gifout.println("<phoneid=/""+rs.getString(1)+"/">");
http://www.360doc.com/DownloadImg/16915/439483_64.gifout.println("<id>"+rs.getString(1)+"</id>");
http://www.360doc.com/DownloadImg/16915/439483_64.gifout.println("<name>"+rs.getString(2)+"</name>");
http://www.360doc.com/DownloadImg/16915/439483_64.gifout.println("<price>"+rs.getString(3)+"</price>");
http://www.360doc.com/DownloadImg/16915/439483_64.gifout.println("<image>"+rs.getString(4)+"</image>");
http://www.360doc.com/DownloadImg/16915/439483_64.gifout.println("</phone>");
http://www.360doc.com/DownloadImg/16915/439483_64.gif}
http://www.360doc.com/DownloadImg/16915/439483_64.gif
http://www.360doc.com/DownloadImg/16915/439483_64.gifrs.close();
http://www.360doc.com/DownloadImg/16915/439483_64.gifstmt.close();
http://www.360doc.com/DownloadImg/16915/439483_64.gifconn.close();
http://www.360doc.com/DownloadImg/16915/439483_64.gif
http://www.360doc.com/DownloadImg/16915/439483_64.gif}catch(Exceptione){
http://www.360doc.com/DownloadImg/16915/439483_64.gifout.println(e);
http://www.360doc.com/DownloadImg/16915/439483_64.gif}
http://www.360doc.com/DownloadImg/16915/439483_64.gif%>
http://www.360doc.com/DownloadImg/16915/439483_64.gif</phonelist>
http://www.360doc.com/DownloadImg/16915/439483_64.gif
mobile.mxml
这里要注意一下<mx:HTTPService>中的resultFormat="xml"的设置,在这里应该把这个取掉(我原来是用来做Tree用的)。phonelisg.jsp和mobile.mxml放在相同的目录下,当然你也可以修改url的路径。
http://www.360doc.com/DownloadImg/16915/439483_7.gif<?xmlversion="1.0"encoding="utf-8"?>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Applicationxmlns:mx="http://www.macromedia.com/2003/mxml"
http://www.360doc.com/DownloadImg/16915/439483_7.gifverticalGap="10"
http://www.360doc.com/DownloadImg/16915/439483_7.gifbackgroundColor="#FFFFFF"
http://www.360doc.com/DownloadImg/16915/439483_7.gifpageTitle="手机"
http://www.360doc.com/DownloadImg/16915/439483_7.gifinitialize="initApp()">
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Stylesource="main.css"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:HTTPServiceid="phoneService"url="phonelist.jsp"resultFormat="xml">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:request>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<categoryID>{categoryId}</categoryID>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:request>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:HTTPService>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Modelid="phonelist">
http://www.360doc.com/DownloadImg/16915/439483_7.gif{phoneService.result.phonelist.phone}
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Model>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Script>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<![CDATA[
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gifvarcategoryId=2;
http://www.360doc.com/DownloadImg/16915/439483_7.gifvarcategoryName="Moto";
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.giffunctioninitApp(){
http://www.360doc.com/DownloadImg/16915/439483_7.gifphoneService.send();
http://www.360doc.com/DownloadImg/16915/439483_7.gif}
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif]]>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Script>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:HBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:LinkBarstyleName="title"width="500"click="">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:dataProvider>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Array>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Objectlabel="首页"link="main"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Objectlabel="手机分类"link="catagory"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Objectlabel="论坛"link="forum"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Objectlabel="关于"link="about"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Array>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:dataProvider>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:LinkBar>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Labeltext="搜索"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:TextInputid="key"width="120"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Buttonlabel="Go"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:HBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:HBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Imagesource="images/qd_2.jpg"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Labelid="debug"text="123"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:HBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Effect>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Zoomname="zoomBig"zoomTo="107"duration="100"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Zoomname="zoomSmall"zoomTo="100"duration="100"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Effect>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:HBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Panelid="main"title=""height="360">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Tilewidth="520">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Repeaterid="plist"dataProvider="{phonelist}"startingIndex=""count="">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:VBoxid="itemBox"verticalGap="0"horizontalAlign="center"mouseUp="">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Canvaswidth="100"height="100"clipContent="false">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Imagewidth="90"height="90"source="{plist.currentItem.image}"toolTip="RMB{plist.currentItem.price}"mouseOverEffect="zoomBig"mouseOutEffect="zoomSmall"visible="false"complete="event.target.visible=true;"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Canvas>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Labelid="itemName"text="{plist.currentItem.name}"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Labelid="itemPrice"text="RMB{plist.currentItem.price}"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:VBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Repeater>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Tile>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:ControlBar>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Buttonlabel="上一页"click=""/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Buttonlabel="下一页"click=""/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Buttonlabel="refresh"click="initApp()"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:ControlBar>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Panel>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:HBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:HBoxhorizontalAlign="center">
http://www.360doc.com/DownloadImg/16915/439483_7.gif<mx:Labeltext="CopyRight2004dannyr'sStudio"/>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:HBox>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</mx:Application>
http://www.360doc.com/DownloadImg/16915/439483_7.gif
最后:配置Flex服务器
flex-config.xml
http://www.360doc.com/DownloadImg/16915/439483_7.gif<http-service-proxy>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<whitelist>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<unnamed>
http://www.360doc.com/DownloadImg/16915/439483_7.gif<url>http://{localserver}/flex/phonelist.jsp</url>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</unnamed>
http://www.360doc.com/DownloadImg/16915/439483_7.gif</whitelist>
http://www.360doc.com/DownloadImg/16915/439483_7.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gifhttp://www.360doc.com/DownloadImg/16915/439483_184.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif</http-service-proxy>
【本文转自网络无名氏】
另附几篇文章:
Flex与Servlet通讯
RIA技术入门之Macromedia Flex & JSP(一)
RIA技术入门之Macromedia Flex & JSP(二)
RIA技术入门之Macromedia Flex & JSP(三)
RIA技术入门之Macromedia Flex & JSP(四)
简单的flex 2 mysql jsp实例
<!-- Google Reader shared发布代码开始 --><script type="text/javascript" src="http://www.google.com/reader/ui/publisher.js"></script><script type="text/javascript" src="http://www.google.com/reader/public/javascript/user/00697638153916680411/state/com.google/broadcast?n=5&callback=GRC_p%28%7Bc%3A%22green%22%2Ct%3A%22%5Cu8FD9%5Cu4E9B%5Cu6587%5Cu7AE0%5Cu4E5F%5Cu503C%5Cu5F97%5Cu4E00%5Cu770B%22%2Cs%3A%22false%22%7D%29%3Bnew%20GRC"></script><!-- Google Reader shared发布代码结束 --> |
|