前端 velocity(.vm)模板里写ajax出现解析异常
异常信息:
Caused by: org.apache.velocity.exception.ParseErrorException: Encountered "{" at distribute/alltranslator.vm[line 303, column 16] Was expecting one of: <EOF> "(" ... <RPAREN> ... <ESCAPE_DIRECTIVE> ... <SET_DIRECTIVE> ... "##" ... "\\\\" ... "\\" ... <TEXT> ... "*#" ... "*#" ... <STRING_LITERAL> ... <IF_DIRECTIVE> ... <STOP_DIRECTIVE> ... <INTEGER_LITERAL> ... <FLOATING_POINT_LITERAL> ... <WORD> ... <BRACKETED_WORD> ... <IDENTIFIER> ... <DOT> ... "{" ... "}" ...
明明前端js代码写的没问题,但就是出现了异常,出现异常的那一行的代码为$.ajax(),表面上没问题,但在vm解析的时候,会解析存在的$符号,尽管是jquery的$符,但vm不知道,所以就出现解析错误。
改正:$.ajax() -> jQuery.ajax()
本文来自博客园,作者:wzyy,转载请注明原文链接:https://www.cnblogs.com/wwzyy/p/10308181.html