简体   繁体   中英

How to pass huge string data from javascript to java action class?

Is that possible to pass huge string data from javascript to java action class?

var url = "xwe.action?pdfDivContent=" + encodeURIComponent(div1);
    alert( url);
    req.open("POST", url, true);
    req.send(null)

I tired the above code and it is not working as pdfDivContent is huge in size(#approx 2000 characters.

You are sending the data via GET not post. You should be putting the data in send, not the querystring. This is assuming that div1 actually holds a string.

var url = "xwe.action";
req.open("POST", url, true);
req.send("pdfDivContent=" + encodeURIComponent(div1))

Based on your comment, maybe you need to set these headers

var url = "xwe.action";
req.open("POST", url, true);
var params = "pdfDivContent=" + encodeURIComponent(div1);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", params.length);
req.setRequestHeader("Connection", "close");
req.send(params);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM