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();
相关文档:
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
try {
Class cls = com.lwf.util.CommonUtil.class;
Object obj = cls.newInstance();
Method addMethod = cls.ge ......
要理类加载体系结构,就必须清楚如下几点比较基本的原则:
1. classLoader是一种父子树形结构(注:这里不是指类继承的父子关系)
2. 父classLoader无法看到子classLoader加载的类
3、虚拟机遵守双亲委托加载原则,即任何子classLoader须首先委托父classLoader先加载需要的类,当父classLoader加载不到时再由子classLoa ......
比如java中常用的运算符
一 符号++ ,+,--,-
有时这个符号拼凑起来也有点复杂
比如这样一个运算式
int i=3;
i+++i-i++-++i
+ -运算符的优先级 低于++,-- 先运算++,--
可以将上面的式子拆开
i++ + i - i++ - ++i
这样是不是容易多了
先来个简单点的
1 K++
int k=0;
System.out.println(K++)
System.o ......
下面开讲故事:
从前有个房间,房间里有份文档,房间还有一把钥匙。 这把钥匙在张三手里。
这时李四来向张三要那份文档。 张三不太喜欢李四,但又怕耽误了
工作不好交代。于是张三就把房间里文档的文档复印了一份,然后把那个复印件交给了李四(这叫传值)。
李四拿到文档后(复印件),胡乱修改一 ......
三年前,用过AmfPHP与Flash/Flex
Remoting做过交互,最近接触Python,公司项目用的Flex做前端,所以接触了PyAmf。PyAmf本质上跟AmfPHP是雷同的。都是通
过对AMF协议(ActionScript Message Format)协议的支持来实现对Flash的交互过程。
一、首先,简单的介绍一下AMF协议格式。
AMF是Adobe独家开发出来的通信协议,它采 ......