繁体   English   中英

如何在HTML标签中包含变量JSP?

[英]How to include a variable JSP into a HTML label?

我有一个JSP文件,可以从HTML文件中的表单按钮调用它。 在此JSP中,我从表单的下拉列表中选择了选项,该选项保存在变量“ topic”中。

在此JSP文件中,我还有另一个按钮必须调用Javascript函数crearframe()。 该参数必须是保存在变量“ topic”中的值。 我怎样才能做到这一点?

当用户按下按钮时,我需要打开另一个HTML文件,具体取决于变量“ topic”的值。 html文件的名称将为“ topicValue” +“ .html”。

有什么办法吗?

非常感谢你。

这是代码。

<script language="javascript">  
function crearframe(htmlFilePath) {
var testframe = document.getElementById("iframe");
testframe.src = htmlFilePath + ".html"; 
}
</script>
</head>

<body>
<table width="100%">
<tr>
<td align="center" valign="top">

<% 
String topic = request.getParameter("opcion");
out.println("<H2>Resultado del análisis sobre " + topic + "</H2>");
%>

<div id="grafica"></div>
<table width="80%">
<tr>
     <td align="center" width="25%">
         <button type="button" name="Analizar1" class="btn btn-primary"  Onclick="crearframe('HaveToBeTheTopicVariable')" >Ver;</button>                

使用Scriptlets以这种方式进行

Onclick="crearframe('<%= topic %>')"

我从不建议您使用Scriptlets而不是JSP标准标记库

看看如何避免JSP文件中的Java代码?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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