我有一個用戶界面,讓用戶輸入他想要的任何值(字串值)
該值可以包含任何字符,包括{{
和,}}
例如{{.}}
或{{/}}
值示例
text{{.}}here
text{{\}}here
我有一個使用 angularjs 的 jsp 頁面,它使用<c:out value="${stringValue}"/>
我的錯誤是
angular.js:15697 Error: [$parse:syntax] Syntax Error: Token '.' not a primary expression at column 1 of the expression [.] starting at [.].
https://errors.angularjs.org/1.8.3/$parse/syntax?p0=.&p1=not a primary expression&p2=1&p3=.&p4=.
at angular.js:138:1
at AST.throwError (angular.js:16255:1)
at AST.primary (angular.js:16143:1)
at AST.unary (angular.js:16121:1)
at AST.multiplicative (angular.js:16108:1)
at AST.additive (angular.js:16099:1)
at AST.relational (angular.js:16090:1)
at AST.equality (angular.js:16081:1)
at AST.logicalAND (angular.js:16073:1)
at AST.logicalOR (angular.js:16065:1)
.
它試圖評估{{.}}
我正在尋找一種解決方案來停用值文本中的運算式語言,stringValue
這樣它就會在text{{.}}here
不評估的情況下出現{{.}}
根據我的發現,我們可以通過以下方式停用整個 jsp 頁面的運算式語言
<%@ page isELIgnored ="true" %>
但我只想為這個值而不是整個頁面停用它
有任何想法嗎?
uj5u.com熱心網友回復:
<%@ page isELIgnored ="true" %>
不是解決方案,因為錯誤不在JSP處理中,而是在AngularJS處理中。
例如,如果您有一個 JSP 頁面,例如
<h1><c:out value="${stringValue}"/><h1>
JSP 將生成一個 HTML 頁面,其中包含:
<h1>Text{{.}}Text<h1>
由 angularJS 解釋,并引發錯誤。
解決方案是使用指令禁用 angularJS 解釋ngNonBindable
。angularJS 不會使用該指令解釋元素的內容。
<h1 ng-non-bindable><c:out value="${stringValue}"/><h1>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/507798.html
上一篇:串列不會自動更新撰寫