<head> #set($test = "works")) </head>
<script>
var get = "${test}"; // I also tried using '$test' and "$test" also
alert(get);
</script>
而且它提醒了$ {}測試,但應打印工作。訪問速度可變
我怎樣才能使它工作?
<head> #set($test = "works")) </head>
<script>
var get = "${test}"; // I also tried using '$test' and "$test" also
alert(get);
</script>
而且它提醒了$ {}測試,但應打印工作。訪問速度可變
我怎樣才能使它工作?
試試這個...
#set ($test = "works")
<script type="text/javascript">
var myvar = "${test}";
alert (myvar);
</script>
這無疑WORKS !!!!
我在使用的瓷磚有這個問題,我就開始工作的唯一方法是使用JSTL C:出標籤,如:
var get = "<c:out value='${test}' />";
應該工作,並記得添加了JSTL包括在頁面的頂部
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
我意識到這個問題是舊的,但這個工作對我來說:
#set ($test = "hi")
<script>
alert("$test");
</script>
氖因爲它是一個字符串,所以要在alert中包含引號。
只是用它作爲HTML:
<script>
var get = $test;
alert(get);
</script>
我使用了單引號,但現在打印了「$ test」。你的意思是將速度代碼放在
標籤中?同樣的事情。查看我的更新問題 – Jaanus你有沒有試過這個? 。 –
不適用於我,$ {test}或者「$ test」或者「$ test」 – Tino