设为首页 收藏本站
查看: 803|回复: 0

[经验分享] Adobe Flex与后台JSP+Mysql+Sevlet结合的若干例子

[复制链接]

尚未签到

发表于 2016-10-23 08:37:26 | 显示全部楼层 |阅读模式
<!-- 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&amp;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.gif
createtabletblmobile
http://www.360doc.com/DownloadImg/16915/439483_7.gif(
http://www.360doc.com/DownloadImg/16915/439483_7.gifid
integer(11)notnulldefault0
,
http://www.360doc.com/DownloadImg/16915/439483_7.gifcategoryid
integer(11
),
http://www.360doc.com/DownloadImg/16915/439483_7.gifname
varchar(255
),
http://www.360doc.com/DownloadImg/16915/439483_7.gif
imagevarchar(255
),
http://www.360doc.com/DownloadImg/16915/439483_7.gifprice
decimal(12,2
),
http://www.360doc.com/DownloadImg/16915/439483_7.gifaddtime
datetime
,
http://www.360doc.com/DownloadImg/16915/439483_7.gif
primarykey
(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.gif
createindexi_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.gif
createuniqueindexpk_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.gif
createindexi_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.gif
Stringsql="";
http://www.360doc.com/DownloadImg/16915/439483_7.gif
Stringurl="";
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif
StringcategoryID=request.getParameter("categoryID");
http://www.360doc.com/DownloadImg/16915/439483_7.gif
http://www.360doc.com/DownloadImg/16915/439483_7.gif
try{
http://www.360doc.com/DownloadImg/16915/439483_1.gifhttp://www.360doc.com/DownloadImg/16915/439483_2.gif
Class.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.gif
while(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&amp;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发布代码结束 -->

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-290042-1-1.html 上篇帖子: Windows2003下配置 Apache2.2 + MySQL 5 + php5 + ZendOptimizer3.3 + .htaccess重写 下篇帖子: MYSQL不支持正则替换!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表