日期:2014-05-16  浏览次数:20344 次

Jquery js url 传值乱码终究解决方案
$("#subForm").click(function() {
			var bookcaseId = $.trim($("#bookcaseId").val());
			[color=red]bookcaseId = encodeURI(encodeURI(bookcaseId));[/color] //用了2次encodeURI 
				if (bookcaseId) {
					var url = "../book!retrieveBillNo.action";
					$.ajax( {
						url : url,
						cache : false,
						async : false,
						type : "POST",
						dataType : "json",
						success : function(data) {
							/*	$("form").attr(
										"action",
										"choose.jsp?bookcaseId="
												+ bookcaseId + "&result="
												+ data.name); */
							location.href = "choose.jsp?bookcaseId="
									+ bookcaseId + "&result=" + data.name;
						}
					});
				}
				$("#bookcaseId").focus();

			});



request.setCharacterEncoding("UTF-8");
	String bookcaseId = request.getParameter("bookcaseId");
	[color=red]bookcaseId = java.net.URLDecoder.decode(bookcaseId, "UTF-8");[/color]	if (null != bookcaseId) {
		session.setAttribute("bookcaseId", bookcaseId);
	}
1 楼 kingsmalltwo 2012-05-24  
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");

这样在JAVA里面写前台的String串就不乱码了。