易截截图软件、单文件、免安装、纯绿色、仅160KB

Flex和Java交互的乱码解决方案


今天做Flex时碰到flex和java交互的乱码问题,使用HTTPService无论是从Flex端传到Java端,还是反过来都乱码。调查了半天,终于搞定了。
 
 
以下是解决方案:
 
 
1.Flex端传到Java端
 
Flex端:encodeURIComponent(comment.text)
使用encodeURIComponent把参数转换为 application/x-www-form-urlencoded 格式
 
Java端:URLDecoder.decode(comment, "utf-8")
对 x-www-form-urlencoded 字符串解码
 
2.Java端传到Flex端
 
 
 
 
 
HttpServletResponse response = ServletActionContext.getResponse();
PrintWriter out = response.getWriter();
response.setContentType("text/html;charset=utf-8");

out.println(doc.asXML());
out.flush();
out.close();



HttpServletResponse response = ServletActionContext.getResponse();
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/html;charset=utf-8");

out.write(doc.asXML().getBytes("UTF-8"));
out.flush();
out.close();  


相关文档:

flex时序图示例

<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the DateTimeAxis class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>

import mx.collections.ArrayCollection;
......

java回调机制


java回调机制
 
回调概念:
软件模块之间总是存在着一定的接口,从调用方式上,可以把他们分为三类:同步调用、回调和异步调用。同步调用是一种阻塞式调用,调用方要等待对方执行完毕才返回,它是一种单向调用;回调是一种双向调用模式,也就是说,被调用方在接口被调用时也会调用对方的接口;异步调用是一种类似 ......

Java SE 接口、抽象类

package demo;
interface Runner{
 int ID=1;
 void run();
 void fly();
}
abstract class AI implements Runner{
 public void run(){
  System.out.println("I am running");
 }
 public void bb(int x,int y){
  System.out.println((x+y));
 }
& ......

flex DataGrid编辑单元格并获取新的值

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Panel width="458" height="313" layout="absolute">
<mx:Label id="lbl" x="19" y="10" text="" width="171" height="20"/>
<mx:DataGrid id="dg" x="19" y="58" dataProvider="{arr}" editable="true" ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号