我在js中一定要打开新窗口进行业务的受理,不能进行form1.submit();操作,但是javascript中字符串类型长度不够(如里面的url),导致js走不下去,想问一下些高手js里面有没有可以存放很大长度的对象?
(PS:不想用java里面的session来做,如果要那样做我程序改动较大,所以想保持js的方式)
function createCust{
var url = "createCust.jsp?a=aa&b=bb".....;//url好长~~~参数N多
window.showModalDialog(url,window,"dialogWidth:450px;dialogHeight:300px;status:no;help:no;");
}
(PS:不想用java里面的session来做,如果要那样做我程序改动较大,所以想保持js的方式)
function createCust{
var url = "createCust.jsp?a=aa&b=bb".....;//url好长~~~参数N多
window.showModalDialog(url,window,"dialogWidth:450px;dialogHeight:300px;status:no;help:no;");
}
是否可以考虑将该超长url变量拆分后分别装入数组,再将该数组传递到createCust.jsp页面。
function sendurl()
{
var a = new Array();
var url = "a=aa&b=bb".....; //url好长~~~参数N多
a.push(url);
return a.join('&');
} window.showModalDialog("createCust.jsp?"+sendurl(),window,'scroll:0;status:0;help:0;resizable:0;dialogWidth:480px;dialogHeight:370px');
</script> *****************jsp页面取值:*******************
Enumeration paramnames = request.getParameterNames();
String param = null;
while(paramnames.hasMoreElements())
{
param = (String)paramnames.nextElement();
String value = request.getParameter(param);
}
Your javascript is on client side and the jsp are generated by the server. To pass values from client to server, the only way is to put them in a form as rollingpig suggested. You CAN NOT pass object from client to server, I guess, that is what you want to do about the "Array". However, there is a way to pass object from jsp to jsp on the same app server, that is using request's session object. So if your javascript's array data was originally created from server, you can do it by using session object. If your javascript's array data depend on client's input, then simply you don't have other choices.好奇的问一下lz为什么会一下传递N多的参数到服务器端?
lz再想想别的传值方法,不要使用url传参。
还是你比较细心呐,呵呵 我做的是营业厅开户的功能,数据量比较大,我做的时候就是用了form[0].submit()的方法,很多数据是用ajax load 出来的,但是如果提交的数据出错了(指在数据库中的逻辑判断出错),用历史返回得不到页面原先的数据,这样不怎么方便...所以要改~郁闷呐,只能这样写了,呵呵