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();
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
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 ......
java回调机制
回调概念:
软件模块之间总是存在着一定的接口,从调用方式上,可以把他们分为三类:同步调用、回调和异步调用。同步调用是一种阻塞式调用,调用方要等待对方执行完毕才返回,它是一种单向调用;回调是一种双向调用模式,也就是说,被调用方在接口被调用时也会调用对方的接口;异步调用是一种类似 ......
package demo;
class TestA{
public int devide(int x,int y) throws ArithmeticException , DevideByMinusException{
if(y<0)
throw new DevideByMinusException("被除数为负",y);
int result=x/y;
return result;
}
}
public class TestE ......