<a href="products.action?type=笔记本" ></a>
到struts上拿的时候乱码了,求大神指导!
* @see 接受客户端请求的数据(String)
* @param paramName 参数名称
* @return String
* */
public String paramString(String paramName) {
String result = paramStr(paramName);
try {
if ("GET".equalsIgnoreCase(getRequest().getMethod())) {
if (getRequest().getHeader("User-Agent").toLowerCase().indexOf("MSIE".toLowerCase()) != -1) {
result = new String(result.getBytes("ISO-8859-1"), "GBK");
} else {
result = new String(result.getBytes("ISO-8859-1"), "UTF-8");
}
}
} catch (Exception e) {}
return result;
}
/**
* @see 获得request
* @return HttpServletRequest
* */
public HttpServletRequest getRequest() {
return ServletActionContext.getRequest();
}
// 接收客户端请求的数据
private String paramStr(String paramName) {
return (null != getRequest().getParameter(paramName)) ? getRequest().getParameter(paramName) : "";
}
用最上边这个方法试试,包你没乱码