簡體   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