$ {}模板文字(ES2015)在jsp页面下工作

问题描述 投票:0回答:1

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
	
</head>
<body>
	<h2> why ${variableName} is in consider as undefined in jsp page
	<script>
		let x;
		console.log(`${x} this the variable`)

	</script>
</body>
</html>

$ {}在jsp页面中被认为是未定义的。请告诉我它是如何扩展的。谢谢!

javascript jsp ecmascript-5
1个回答
0
投票
解决方法是使用反斜杠对$ {myVar}进行转义,以便JSP忽略它:
© www.soinside.com 2019 - 2024. All rights reserved.