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();
相关文档:
package org.mingyuan.fetcher;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
i ......
要理类加载体系结构,就必须清楚如下几点比较基本的原则:
1. classLoader是一种父子树形结构(注:这里不是指类继承的父子关系)
2. 父classLoader无法看到子classLoader加载的类
3、虚拟机遵守双亲委托加载原则,即任何子classLoader须首先委托父classLoader先加载需要的类,当父classLoader加载不到时再由子classLoa ......
下面开讲故事:
从前有个房间,房间里有份文档,房间还有一把钥匙。 这把钥匙在张三手里。
这时李四来向张三要那份文档。 张三不太喜欢李四,但又怕耽误了
工作不好交代。于是张三就把房间里文档的文档复印了一份,然后把那个复印件交给了李四(这叫传值)。
李四拿到文档后(复印件),胡乱修改一 ......
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));
}
& ......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Panel width="392" height="300" layout="absolute">
<mx:Label x="19" y="10" text="{user}" width="171" height="20"/>
<mx ......