日期:2014-05-18  浏览次数:20787 次

数据库中存了含有汉字的url,结果正确无误,取出后,当使用URLEncoder.encode进行转码后发现问题
首先可以正确的取出数据,数据为“dep=研发&sex=男”,结果使用了URLEncoder.encode后发现,数据中的“=”和“&”也全部转码了,但是我只要求汉字进行转码,其他符号转码就错了,请各位高人赐教

public   ActionForward   displayJspParam(ActionMapping   mapping,
ActionForm   form,   HttpServletRequest   request,
HttpServletResponse   response)   throws   Exception
{
Task   task=deptManagerService.getOneTask(new   Integer(3));

String   urlparam=task.getParaminfo();

String   str= "/ "+ "notag/ "+ "params.jsp? "+URLEncoder.encode(urlparam, "gb2312 ");

ActionForward     forward=new   ActionForward();/**自己构建一个actionforward*/      

forward.setPath(str);      

forward.setRedirect(true);

return   forward;
}

------解决方案--------------------
url不能用中文的吧
------解决方案--------------------
将汉字提取出来 转码后再拼合