Yesterday in debugging a project effect, the dead or dead out, with a chrome debugging, found a mistake: uncaught syntaxerror:unexpected token; After I navigate to the JSP file, I find the location is my HTML header file declaration: <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "http://www.w3c.org/TR/1999/REC-html401-19991224/ Loose.dtd "", I ordered the other page found no report this error, after a comparison of verification, to find the problem, the problems of the page application of the dynamic JS file: <script type= "Text/javascript" src= "${_" CONTEXTPATH}/${DETAILJS} "></script>, where the Datailjs did not find, (I was careless forgot to configure), led to the corresponding error, but I am not satisfied with this, want to know the root cause of the problem,
I use the Chrome Debug error page to view the JS code:
<script type= "Text/javascript" src= "/aabbcc/" ></script>
I think it is possible to refer to the JS source file path is not all caused, I did an experiment, I manually added the JSP page code as follows a JS reference;
<script type= "Text/javascript" src= "/aaa/" ></script>
Then chrome debugging, the error is as follows:
Get http://hello.cas.server:9080/aaa/404 (not Found)
, not as the title of the Uncaught syntaxerror:unexpected token, this is another I am very puzzling, after some thinking, I found a phenomenon, the page I quote the following JS:
<script type= "Text/javascript" src= "${_contextpath}/${detailjs1}" ></script>
<script type= "text /javascript "src="/aaa/"></script>
Build page:
<script type= "Text/javascript" src= "/boss_nqcp_manage/" ></script>
<script type= "Text/javascript" src= "/aaa/" ></script>
Chrome Error Results:
Get http://hello.cas.server:9080/aaa/404 (not Found)
index.do:20uncaught syntaxerror:unexpected Token <
We found that the problem is not, I was quoted after the/aaa/, but did first reported that it's wrong, it explains a problem, is that the JSP page will first handle the static reference page, which means that the address of the reference file is not a dynamic parameter of the page,
Then I used the real existence of the project path to do the test, test JS:
<script type= "Text/javascript" src= "/boss_nqcp_manage/resource/" ></script>
Build page:
<script type= "Text/javascript" src= "/boss_nqcp_manage/resource/" ></script>
The Chrome error is the same as the headline,
My conclusion is as follows: When JS refers to a file that is a folder under the project path, this error is reported.