AJAX 呼び出しを使用して jsp を呼び出しています。
var httpRequest = null;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
if (!httpRequest) {
console.error('Cannot create an XML HTTP instance');
return false;
}
httpRequest.onreadystatechange = function() {
try {
if(httpRequest.readyState === 4) {
...
}
} catch(e) {
args.error(e);
}
};
httpRequest.open(args.method, args.path, args.sync);
httpRequest.setRequestHeader(...);
var q = '', first = true;
for(var key in args.params) {
if(params.hasOwnProperty(key)) {
if(first) {
first = false;
} else {
q += '&';
}
q += encodeURIComponent(key) + '=' + encodeURIComponent(args.params[key]);
}
}
httpRequest.send(q);
このリクエストでは、クエリ パラメータを次のように渡します。
{
from: 'xyz',
to: 'abc'
}
構築されているクエリも正しいです。
from=xyz&to=abc
ただし、私の JSP では、 を実行するrequest.getParameter("from")
と が得られnull
ます。これを修正するにはどうすればよいですか?