易截截图软件、单文件、免安装、纯绿色、仅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();  


相关文档:

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 Reflection 浅析1

Reflection 的简单应用,包括field, method,constructor的应用。
package com.gaoqian.reflection;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Typ ......

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 ......

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号