读书人

js 交付action

发布时间: 2012-09-11 10:49:03 作者: rapoo

js 提交action

JScript code
        function upload(enterid){            // document.all('formname').method = "get";            document.all('formname').action="uploadsinglepic?enterid="+enterid;            alert(enterid);            document.all('formname').submit();        }

我在Struts2 action中

System.out.println(enterid);
System.out.println(ServletActionContext.getRequest().getParameter("enterid"));
都无法获取enterid值?

求帮助!!!

[解决办法]
不行,不能用 form 来提交带参数URL。

你只能先在<form>中定义一个隐藏域:
<input type="hidden" id="enterid" name="enterid">

然后JS中:
document.getElementById("enterid").value = enterid;
[解决办法]
你要是get方式,根本不需要提交form,
只有window.href或replace你的带?好的url就好了。

探讨

document.all('formname').method = "get"; 加上这样的也不行吗?
为什么<a href></a> 这种方式却能Get
是不是js 底层根本没有实现Get方式?

[解决办法]
探讨
不行,不能用 form 来提交带参数URL。

你只能先在<form>中定义一个隐藏域:
<input type="hidden" id="enterid" name="enterid">

然后JS中:
document.getElementById("enterid").value = enterid;

[解决办法]
探讨

引用:
不行,不能用 form 来提交带参数URL。

你只能先在<form>中定义一个隐藏域:
<input type="hidden" id="enterid" name="enterid">

然后JS中:
document.getElementById("enterid").value = enterid;


[解决办法]
document.myform.action="mexposure_approved.action?stateType=pmcApproved&id="+id+"&customerCode="+cusCode;
document.myform.submit();


这样是可以的,action里要有stateType属性的get\set方法

读书人网 >J2EE开发

热点推荐