window.open("/stms/aboutGrant.jsp?grantCode="+ code+"&grantName="+ encodeURIComponent(name),"aboutGrant","width=500,height=200,status=yes,resizable=no,top=280,left=300");
像这种jsp转jsp传值 用${param.grantName}得到的是乱码;
还有<a href="/stms/uploadCommand.do downFile=_&fileCode=0&TemplatefileName=${grantInfo.feasible_template}"target="frameDownLoad"><img src="/stmsres/images/index/ico_outline.gif" width="16" height="16" /></a>
还有这种jsp转java传值并且${grantInfo.feasible_template}是已经进行了java.net.URLEncoder.encode编码的字符串,但是传到后台一样的出现了乱码,tomcat,jsp,java都设置了编码格式为utf-8,求高手解答。jspjavatomcat
像这种jsp转jsp传值 用${param.grantName}得到的是乱码;
还有<a href="/stms/uploadCommand.do downFile=_&fileCode=0&TemplatefileName=${grantInfo.feasible_template}"target="frameDownLoad"><img src="/stmsres/images/index/ico_outline.gif" width="16" height="16" /></a>
还有这种jsp转java传值并且${grantInfo.feasible_template}是已经进行了java.net.URLEncoder.encode编码的字符串,但是传到后台一样的出现了乱码,tomcat,jsp,java都设置了编码格式为utf-8,求高手解答。jspjavatomcat
String deName = java.net.URLEncoder.decoder(request.getParameter("name"));
参数=new String(参数.getBytes("gbk"),"utf-8"); 回复于: 2013-03-01 11:57:38
参数=new String(参数.getBytes("gbk"),"utf-8");
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
URIEncoding="UTF-8"就支持url传中文了
org.springframework.web.filter.CharacterEncodingFilter
初始化为UTF-8
//在弄超链接时可以这样
<a href=".....?name=<%RULEncoder.encode("中国","UTF-8")%>"> //解码
String name=requst.getParameter("name");
//此时应该是乱码
String name1=new String(name.getBytes[],"UTF-8");
//这个步骤过后,name1应该可以解码成你编码之前要传输的值了,当然utf-8这个是我编码时的格式,你根据你的编码替换掉
);
var param = “中文”;
param = URLencode(URLencode(param));
再传到后台。
用encodeURL解码就OK
不行啊! 我的链接是上面的样子,但是我用request得到它就是乱码,如果是写在JS中的话可以用encodeURIComponent对TemplatefileName参数进行处理那么得到的就不是乱码,但是我要用在html中
<c:forEach items="${grantInfoList}" var="grantInfo">
<c:choose>
<c:when test="${grantInfo.feasible_template!=null}">
<a href="/stms/uploadCommand.do downFile=_&fileCode=0&TemplatefileName=${grantInfo.feasible_template}" target="frameDownLoad"><img src="/stmsres/images/index/ico_outline.gif" width="16" height="16" />
</a>
</c:when>
<c:otherwise>--</c:otherwise>
</c:choose>
</c:forEach>此值${grantInfo.feasible_template}我是已经在后台进行过编码传过来的。后台接收fileName = URLDecoder.decode(request.getParameter("TemplatefileName"),"utf-8");
如果有好的方法,请写一下代码,感激不尽。
function encodeURIStr(str){
str = str.replace(/:/g, '%3A');
str = str.replace(/@/g, '%40');
str = str.replace(/&/g, '%26');
str = str.replace(/=/g, '%3D');
str = str.replace(/#/g, '%23');
str = str.replace(/\+/g, '%2B');
return str;
}