【问题标题】:How to pass the parameter using showModalDialog如何使用 showModalDialog 传递参数
【发布时间】:2013-08-31 00:41:19
【问题描述】:

我有一个问题。

我在 JSP 文件中写了以下内容。

<s:url id="printURL" action="actMod" method="printout">
    <s:param name="txt_ActEdit_accid"><s:property value="%{txt_ActEdit_accid}" /></s:param>
    <s:param name="txt_ActEdit_accffname"><s:property value="%{txt_ActEdit_accffname}" /></s:param>
    <s:set var="loginPassword"><%=OpeCommon.LOGIN_PASSWORD %></s:set>
    <s:param name="%{#loginPassword}"><%=OpeCommon.encriptPassword(p_userID, p_passCode)%></s:param>
</s:url>
<s:submit name="btn_ActList_print" cssClass="dispLvl3 mediumbutton" value="%{getFieldName('S05AccountEdit.print_button')}"
onclick="javascript:popUp('%{printURL}','elastic',500,500);return false;"/>

我在一个js文件中写了以下内容。

var newWin = null;

function popUp(strURL, strType, strHeight, strWidth) {
  if (newWin != null && !newWin.closed)
    newWin.close();
  var strOptions="";
  if (strType=="console")
    strOptions="resizable,height="+
      strHeight+",width="+strWidth;
  if (strType=="fixed")
    strOptions="status,height="+
      strHeight+",width="+strWidth;
  if (strType=="elastic")
    strOptions="toolbar,menubar,scrollbars,"+
      "resizable,location,height="+
      strHeight+",width="+strWidth;
  newWin = window.open(strURL, 'newWin', strOptions);
  newWin.focus();
}

它知道所有参数值,但是当我更改 JavaScript 函数名称和脚本编码时,它不起作用。我的意思是它只知道第一个参数值(txt_ActEdit_accid)。

<s:submit name="btn_ActList_print" cssClass="dispLvl3 mediumbutton" value="%{getFieldName('S05AccountEdit.print_button')}"
onclick="javascript:printWindow('%{printURL}','',500,500);return false;"/>
function printWindow(x_URL, x_ARG, x_WIDTH, x_HEIGHT)
{
    var x_OPT = "dialogHeight: "+x_HEIGHT+"px; "
    +"dialogWidth: "+x_WIDTH+"px; "
    +"edge: Raised; center: Yes; resizable: Yes; status: Yes;";
    window.showModalDialog(x_URL, x_ARG, x_OPT);
}

如何解决这个问题?

【问题讨论】:

  • 看起来像x_ARG === ''。您可以使用showModalDialog()arguments 参数将一个参数传递给对话框。如果需要多个,则需要创建一个数组或对象来传递更多的值。
  • 如果我使用数组或对象从 X_ARG 传递值,如何从 java action 方法中调用该参数值?
  • 不幸的是,Java 超出了我的知识范围。

标签: java javascript jsp parameters struts2


【解决方案1】:

现在,s:url 标签有问题。

Struts 标签通常转义标签的value。但它会阻止 javascript 正常工作。

需要在s:url标签中添加escapeAmp="false"才能获取其他参数。

【讨论】:

  • 我还有一个问题,拜托。今天,我注意到参数(例如:&lt;s:param name="txt_ActEdit_accffname"&gt;&lt;s:property value="%{txt_ActEdit_accffname}" /&gt;&lt;/s:param&gt;)在弹出页面中没有正确显示日文字体。我在弹出页面(JSP)中写了如下内容。 &lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; 其他日文句子显示正确,但 JScript Popup 中的参数显示不正确。请问您能解释一下吗?提前谢谢!!!
  • 参数未使用页面编码进行编码。您可以手动对其进行编码,也可以将服务器配置为您喜欢的编码。
  • 请给我一些建议来解决我的问题; [链接]stackoverflow.com/questions/19086190/…
猜你喜欢
  • 2011-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-10
  • 2022-08-19
  • 1970-01-01
  • 1970-01-01
  • 2020-10-24
相关资源
最近更新 更多