我有一个场景是
Index.jsp,包含一个js文件,比如temp.js,10来自后端的数据作为JSON,在jquery中,我用onclick属性对象= []创建锚标签。
(for i=0;i<10;i++)
object = new Object();
//setting the different attributes of this object and passing index to the onclick function
<a href="modal.jsp" onClick(i) ></a>
Onclick在Index.js
我需要在js文件中使用Encode.forHtml()。
这里所有的示例都是用Scriptlet显示的。我知道scriptlet只能在jsp中使用。但是我想在js文件中使用Encode.forHtml()。所以有没有人能帮我解释一下js文件的用法?
我尝试了以下方法,但不起作用
sample.js
function test1_outsidejsp()
{
var test = "testforEncode";
var msg = Encode.forJavaScriptBlock(test);
alert(msg);
}
PS:罐子没有问题。我使用了在JSP中编写的脚本