Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSP内部不支持的JavaScript';当我使用java标记时,它不工作_Java_Javascript_Json_Jsp - Fatal编程技术网

JSP内部不支持的JavaScript';当我使用java标记时,它不工作

JSP内部不支持的JavaScript';当我使用java标记时,它不工作,java,javascript,json,jsp,Java,Javascript,Json,Jsp,它不会将“准备就绪!”打印到控制台。当我用chrome调试时,我看到 $( document ).ready(function() { console.log( "ready!" ); var ilceler = "${ilceler}"; }); 我的数据是正确的,但为什么这个函数不起作用。 注意:我的数据包括UTF-8字符。 注2:我可以使用字符串而不是json $( document ).ready(function() { console.log( "ready

它不会将“准备就绪!”打印到控制台。当我用chrome调试时,我看到

$( document ).ready(function() {
    console.log( "ready!" );
    var ilceler = "${ilceler}";
});
我的数据是正确的,但为什么这个函数不起作用。 注意:我的数据包括UTF-8字符。 注2:我可以使用字符串而不是json

$( document ).ready(function() {
    console.log( "ready!" );
    var subChildList = "";
    ilceler = JSON.parse(" [
{"id":"xx","tag":"xx","name":"xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxxxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxxx","fatherid":"66","fathertag":"il"},
{"id":"x","tag":"xx","name":"xxx xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xx\/xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxx","fatherid":"66","fathertag":"il"},
{"id":"xx","tag":"xx","name":"xxxx","fatherid":"66","fathertag":"il"}]");
});

在我看来,您需要删除变量周围的引号

应该如此

var a = ${tag}
console.log(a) >> "It's my tag"

JSP/JSTL解释器将保留这些引号,因此您的对象将被视为字符串值而不是JSON对象。另外,如果您的第二个输出是浏览器中的输出,您可以看到它不是有效的JSON。

您也可以发布JSP/Java标记吗?${ilceler}它是我的JSP/Java标记。
var ilceler=“${ilceler}”是什么应该是什么意思?你有没有试过避开新词?既然您说您使用的是JSON字符串而不是JSON对象,请记住javascript不能识别多行字符串;
var ilceler = ${ilceler};