加載js失敗的解決方法

加載靜態資源(css/js等)遇到的錯誤

Failed to load resource: the server responded with a status of 404 ()php

GET http://localhost:8080/static/js/jquery-3.3.1.min.js net::ERR_ABORTED 404css

解決方案

1 解決方法(isELIgnored="false"

出現問題的片斷爲:html

<script src="${pageContext.request.contextPath }/static/js/jquery-3.3.1.min.js"></script>java

加入isELIgnored="false"jquery

<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>web

而後重啓服務器看看會不會還報這個錯spring

2 解決方法(檢查springmvc.xml配置/是否存在靜態資源攔截)

若使用SSM框架,請檢查:spring-mvc

3 解決方法(IDEA out目錄是否存對應靜態資源)

對於使用了IDEA的朋友,請檢查是否out目錄是否存在對應的js、css等靜態文件。服務器

image-20191220120743402.png

若沒有,請打開Project Structure,添加靜態文件所在目錄到Artifacts -> Output Layout中的<output root>下。mvc

我目前的添加的static文件夾,所以我要添加static到<output root>

作法以下:

image-20191220121209778.png

image-20191220121251672.png

image-20191220121350128.png

image-20191220121422965.png

重啓TOMCAT便可。

相關文章
相關標籤/搜索