中文乱码问题解决方案

  • Post author:
  • Post category:其他


使用URLDecoder.encode和URLDecoder.decode方法转码:

jsp  encode 方法只支持在js中使用

<script>



function click_encodeLink(customerName){




alert(customerName)



location.href = “${ctx}/projectmanage/gcProject/getList?customerName=” + encodeURI(encodeURI(customerName)) ;



}

</script>

A标签调用js就OK了






<a class=”menu”



href=”javascript:click_encodeLink(‘${customerInfo.customerName}’)”



target=”mainFrameName”><span>工程信息</span> </a>

后台接受值转码,OK

String name=java.net.URLDecoder.decode(gcProject.getCustomerName(), “UTF-8”);