Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从window.showModalDialog()调用Servlet_Javascript_Internet Explorer_Jakarta Ee_Servlets_Lifecycle - Fatal编程技术网

Javascript 从window.showModalDialog()调用Servlet

Javascript 从window.showModalDialog()调用Servlet,javascript,internet-explorer,jakarta-ee,servlets,lifecycle,Javascript,Internet Explorer,Jakarta Ee,Servlets,Lifecycle,我正在从window.showModalDialog调用另一个应用程序上下文,但与下面的工作相混淆。在ShowModalDialog中传递参数的代码相同 var myArguments = new Object(); myArguments.param1 = "Hello World :)"; window.showModalDialog("java2sTarget.html", myArguments, ''); 我可以使用以下代码在生成的HTML中读取这些myArguments(参数):

我正在从window.showModalDialog调用另一个应用程序上下文,但与下面的工作相混淆。在ShowModalDialog中传递参数的代码相同

var myArguments = new Object();
myArguments.param1 = "Hello World :)";
window.showModalDialog("java2sTarget.html", myArguments, ''); 
我可以使用以下代码在生成的HTML中读取这些myArguments(参数):

<script>
  document.write(window.dialogArguments.param1);//Hello World :)
</script>
onclick=“window.showModelDialog('http://localhost:7778/app/servlet/test“,myArguments,”)

但据我所知

Servlet  --> Servlet container --> HTML+JS+CSS
所以JS将在最后阶段可用,但我想在第一阶段使用(Servlet)

现在,我需要根据myArguments(参数)在servelt代码中做出一些决定


有没有办法读取servlet代码中的这些myArguments(参数)?

将其作为查询字符串中的请求参数传递

var queryString = "param1=" + encodeURIComponent("Hello World :)");
onclick="window.showModelDialog('http://localhost:7778/app/servlet/test?' + queryString, myArguments, '');" 

不,别无选择。请求URL在模式对话框中无论如何都不可见。

因为主要目的是向用户隐藏查询字符串,以避免误用这些参数。 我试着四处看看

开发人员发送隐藏参数以从源(例如数据库)获取相关信息。我们还知道,我们可以在
窗口中发送隐藏信息。showModalDialog
使用
对话框参数

解决方法:

(i) 在使用
jQuery.getJSON()

(ii)我在servlet端使用google gson API将JavaBean转换为Json字符串

(iii)使用
jQuery.parseJSON

var args = jQuery.parseJSON(json);
window.showModalDialog("pages/"+args.pageName, args, ''); 
我使用
args.pageName
使事情变得动态


请建议改进这项工作。谢谢老师的建议。我从你的回答中学到了很多东西。但这次的主要目标是对用户隐藏查询字符串。
var args = jQuery.parseJSON(json);
window.showModalDialog("pages/"+args.pageName, args, '');