通过Tomcat阀门启用重写后,Javascript被加载了两次

问题描述:

我有一个单页应用程序,并且我正在使用tomcat重写阀将除静态资源以外的所有请求转发到我的index.html.以下是我的rewrite.config的内容:

I have a single page application, and I am using the tomcat rewrite valve to forward all the requests other than static resources to my index.html. Following are the contents of my rewrite.config:

RewriteCond %{REQUEST_URI} (?!.*\.(?:jpg|png|css|js|json|scss|map)$).*$
RewriteRule ^.*$ /index.html [L,QSA]

在完成重写后,我发现我的jQuery库和其他javascript文件加载了两次.这导致应用程序中断.有人可以指出这个问题的潜在根源是什么?

After getting the rewrite to work, I am seeing that my jQuery library, and other javascript files are loading twice. This is causing the application to break. Could someone point out what could be the potential root cause of this issue?

我使用以下答案找到了问题所在:

I found out the issue using this answer: link The issue was that I was missing some of the file tags. My final rewrite rule looks like this:

RewriteCond %{REQUEST_URI} (?!.*\.(?:jpg|png|css|js|json|htm|scss|map|svg|html|favicon\.ico)$).*$
RewriteRule ^.*$ /index.html [L,QSA]