关于idea中web项目添加js文件,路径资源错误的问题[Failed to load resource: the server responded with a status of 404 ()]

问题截图如下

关于idea中web项目添加js文件,路径资源错误的问题[Failed to load resource: the server responded with a status of 404 ()]

显示效果如下

关于idea中web项目添加js文件,路径资源错误的问题[Failed to load resource: the server responded with a status of 404 ()]

解决方法

tomcat8及以后都是utf8编码 (这是tomcat的)所以不用改,但是你的开发环境idea不是呀所以要设置idea的vm环境和tomcat编译的环境【-Dfile.encoding=UTF-8】

关于idea中web项目添加js文件,路径资源错误的问题[Failed to load resource: the server responded with a status of 404 ()]

关于idea中web项目添加js文件,路径资源错误的问题[Failed to load resource: the server responded with a status of 404 ()]

如果更改之后,js效果显示不了,但是没有报错,清除一下浏览器的缓存即可

* 有时浏览器读到的东西是你上一次的东西,新的东西并没有真正更新发布过来,这是就要清除一下缓存。比如在idea中换了张图片 tomcate也重新运行了,但是页面刷新就是还是原来那张图,这种情况经常遇见但是都知道是缓存原因所以清下缓存就搞定了

关于idea中web项目添加js文件,路径资源错误的问题[Failed to load resource: the server responded with a status of 404 ()]