InputStream is = request.getInputStream();
DataInputStream input = new DataInputStream(is);
String str =input.readUTF(); 分离参数方法
public String splitString(String str,String temp){
String result = null;
if (str.indexOf(temp) != -1) {
if (str.substring(str.indexOf(temp)).indexOf("&") != -1) {
result = str.substring(str.indexOf(temp)).substring(str.substring(str.indexOf(temp)).indexOf("=")+1, str.substring(str.indexOf(temp)).indexOf("&"));
} else {
result = str.substring(str.indexOf(temp)).substring(str.substring(str.indexOf(temp)).indexOf("=")+1);
}
}
return result; } 调用this.splitString(str, "id=") 对post和get传递参数分别获取 //获取post参数
StringBuffer sb = new StringBuffer() ;
InputStream is = request.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String s = "" ;
while((s=br.readLine())!=null){
sb.append(s) ;
}
String str =sb.toString(); //防止用get传递参数
if(str.equals("")){
if(request.getQueryString() != null) {
str = request.getRequestURL()+"?"+request.getQueryString();
} else {
str = request.getRequestURL().toString();
}
}
转载自:http://lionlx.iteye.com/blog/787456