我想通过action传递参数,但是参数串里面含有&,当请求到达另外一个页面时却收不到字符‘&’以后的内容这是为什么?
如2.jsp内容:
function doUrl(openurl) { document.forms[0].action = openurl; document.forms[0].submit(); } function send(){ var d = 'cresourcemaintain.do?act=linedetail&lineid=' + lineid; var url = "1.jsp?url="+d; doUrl(url); } send();编码的问题吧
因为&符号有特殊含义的,需要使用JS的encodeURI()或者encodeURIComponent()方法编码,后台再解码以后处理
encodeURI()和encodeURIComponent()方法的区别可以参考这里
[url]http://www.iteye.com/topic/739223[/url]
提交表单跟超链接是不同的两种方式,虽然地址栏上都可以看到我们提交的值,但是:
1.提交表单时,action只是指定我们提交表单的路径,传递的值是