易截截图软件、单文件、免安装、纯绿色、仅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传递参数有两种 :值传递,引用传递
一般引用类型 是引用传递,值类型是值传递
值类型是原始数据类型 包括 int,byte,char short long,boolean,float,double
引用类型就是一般的class类 当然也包括原始数据的封装类型 比如int的
封装类型为Integer
一般情况下:
值传递:
例子 1 public  void show1(int str ......

java classLoader 原则

要理类加载体系结构,就必须清楚如下几点比较基本的原则:
1. classLoader是一种父子树形结构(注:这里不是指类继承的父子关系)
2. 父classLoader无法看到子classLoader加载的类
3、虚拟机遵守双亲委托加载原则,即任何子classLoader须首先委托父classLoader先加载需要的类,当父classLoader加载不到时再由子classLoa ......

Java SE 多线程

package thread;
class TestThread extends Thread {
 public void run(){
  while(true){
   System.out.println(Thread.currentThread().getName());
  }
 }
}
public class ThreadDemo {
 /**
  * @param args
  */
 public static void ......

flex TextInput的restrict应用

发现了一个Flex中TextInput的一个比较有用的属性restrict(约束,限定),先看下例子:
1,<mx:TextInput id="test_ti" width="160" maxChars="20" restrict="0-9" text="0"/>
这样,这个输入框最多只能输入20个字符,只能输入0到9之间的数字了,你如果输入别的是输入不进去的
2,<mx:TextInput id="test_ti" width="1 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号