<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%
String user=new String(request.getParameter("username").getBytes("ISO-8859-1"));
out.println(user);
%>
<%@ page language="java" import="java.util.*" %>
<%
String user=new String(request.getParameter("username").getBytes("ISO-8859-1"));
out.println(user);
%>
problem still.
后将ecCode传入js中,组成url传入后台
之后要解码处理以下为处理查询字段代码:
private Map getQueryMap(String querystr) {
if (querystr == null)
return new HashMap(0);
String[] strarr = querystr.split("&");
String[] keyAndValue = null;
if (strarr != null && strarr.length > 0) {
Map map = new HashMap(strarr.length * 2);
for (int i = 0; i < strarr.length; i++) {
keyAndValue = getKeyAndValue(strarr[i]);
if (keyAndValue != null) {
map.put(keyAndValue[0], keyAndValue[1]);
}
}
return map;
} else
return new HashMap(0); } private String[] getKeyAndValue(String str) {
if (str == null)
return null;
String[] keyAndValue = new String[2];
int pos = str.indexOf("=");
if (pos == -1) {
keyAndValue[0] = str;
} else {
keyAndValue[0] = str.substring(0, pos);
keyAndValue[1] = str.substring(pos + 1, str.length());
}
return keyAndValue;
}
利用以上方法
Map map = getQueryMap(request.getQueryString());
s = (String)map.get("userName");
String dCode = URLDecoder.decode(s,"UTF-8");
就行了!