web 项目中a标签传值(中文)到后台的乱码问题

时间:2021-01-17 07:44:01

web 项目中a标签传值(中文)到后台的乱码问题

jsp页面中的a标签

..............

<c:forEach items="${sellerList }" var="seller" >
<tr class="data-tr">
<td>${seller.order_number }</td>
<td>${seller.name }</td>
<td>${seller.phone }</td>
<td>${seller.sumQty}</td>
<td>¥${seller.sumAmount}</td>
<td>
<a id="redirectUrl" href="/seller/querySellerItem.do?id=${seller.id }&&code=${seller.order_number}&&sellerName=${seller.name}">查看详情</a>
</td>
</tr>
</c:forEach>

..............

jsp页面中的js转码:

..............

<script type="text/javascript">
var href=$("#redirectUrl").attr("href");
href = encodeURI(href);
$("#redirectUrl").attr("href",href);
//alert(href +"==="+$("#redirectUrl").attr("href"));
</script>

..............

后台controller控制器接收传值返回前台页面:

..............

String name=req.getParameter("sellerName3");
try {
name= new String(name.getBytes("ISO-8859-1"),"utf-8");

..............
req.setAttribute("sellerName1", name);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

..............