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);
	}

你可能感兴趣的:(java,jquery,jsp,Ajax,json)