1.
<img id="lay1" src="" />
<script type="text/javascript">
document.getElementById('lay1').src='img?mapfile=temp.map&layername=maplayer1&height=150&imgwidth=35&info='+encodeURI(encodeURI('北京地图'));
</script>
javascript中的encodeURI()函数:
定义和用法
encodeURI() 函数可把字符串作为 URI 进行编码。
语法
encodeURI(URIstring)
参数 |
描述 |
URIstring |
必需。一个字符串,含有 URI 或其他要编码的文本。 |
返回值
URIstring 的副本,其中的某些字符将被十六进制的转义序列进行替换。
源文档 <http://www.w3school.com.cn/js/jsref_encodeuri.asp>
2.在服务器端接受到内容后,进行转码:
String info = request.getParameter("info");
info = URLDecoder.decode(info, "UTF-8");