在我的jsp页面中,我在文件的最后一部分中包含了我需要的JS文件:
<script src="../resources/jquery/js/jquery-2.1.0.min.js"></script>
<script src="../resources/jquery/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="../resources/bootstrap/js/bootstrap.min.js"></script>
<script src="../resources/extras/js/docs.min.js"></script>
<script src="../resources/extras/js/jquery.md5.min.js"></script>
<script src="../resources/extras/js/form_submit.js"></script>
<script src="../resources/extras/js/form_valida.js"></script>
<script src="../resources/extras/js/page_link.js"></script>
<script src="../resources/extras/js/page_load.js"></script>
所有这些文件都放在我项目的/ WEB-INF / view / jsp / resources文件夹中:
但是当我运行项目并在浏览器中打开页面时,找不到文件docs.min.js和form_valida.js。
这是浏览器控制台中的输出:
Um formulário foi enviado com a codificação windows-1252. Ela não possui todos os caracteres Unicode, portanto os dados do usuário podem ter sido corrompidos. Para evitar este problema, a página deve ser modificada para que o formulário seja enviado com a codificação UTF-8. Isso pode ser feito modificando a codificação da própria página para UTF-8 ou especificando accept-charset=utf-8 no elemento form. login
POST http://localhost:8080/loja/login [HTTP/1.1 302 Found 44 ms]
GET http://localhost:8080/loja/privado/dashboard [HTTP/1.1 200 OK 42 ms]
GET http://localhost:8080/loja/resources/bootstrap/css/bootstrap.min.css [HTTP/1.1 200 OK 15 ms]
GET http://localhost:8080/loja/resources/bootstrap/css/bootstrap-theme.min.css [HTTP/1.1 200 OK 7 ms]
GET http://localhost:8080/loja/resources/jquery/css/ui-lightness/jquery-ui-1.10.4.custom.min.css [HTTP/1.1 200 OK 7 ms]
GET http://localhost:8080/loja/resources/extras/css/dashboard.css [HTTP/1.1 200 OK 14 ms]
GET http://localhost:8080/loja/resources/extras/css/table.css [HTTP/1.1 200 OK 15 ms]
GET http://localhost:8080/loja/resources/jquery/js/jquery-2.1.0.min.js [HTTP/1.1 200 OK 35 ms]
GET http://localhost:8080/loja/resources/jquery/js/jquery-ui-1.10.4.custom.min.js [HTTP/1.1 200 OK 19 ms]
GET http://localhost:8080/loja/resources/bootstrap/js/bootstrap.min.js [HTTP/1.1 200 OK 41 ms]
GET http://localhost:8080/loja/resources/extras/js/docs.min.js [HTTP/1.1 404 Not Found 23 ms]
GET http://localhost:8080/loja/resources/extras/js/jquery.md5.min.js [HTTP/1.1 200 OK 28 ms]
GET http://localhost:8080/loja/resources/extras/js/form_submit.js [HTTP/1.1 200 OK 36 ms]
GET http://localhost:8080/loja/resources/extras/js/form_valida.js [HTTP/1.1 404 Not Found 24 ms]
GET http://localhost:8080/loja/resources/extras/js/page_link.js [HTTP/1.1 200 OK 29 ms]
GET http://localhost:8080/loja/resources/extras/js/page_load.js [HTTP/1.1 200 OK 40 ms]
GET http://localhost:8080/loja/resources/extras/js/docs.min.js [HTTP/1.1 404 Not Found 4 ms]
GET http://localhost:8080/loja/resources/extras/js/form_valida.js [HTTP/1.1 404 Not Found 3 ms]
任何人都知道这里会发生什么?
答案 0 :(得分:0)
<script src="${pageContext.servletContext.contextPath}/resources/extras/js/form_valida.js" > </script>
<script src="${pageContext.servletContext.contextPath}/resources/extras/js/docs.min.js" > </script>
通过提供完整路径尝试这可能是可行的
答案 1 :(得分:0)
/ WEB-INF / view / jsp / {FOLDER你运行它的项目} / {你的文件包含你的JS文件}如果你在另一个放在上层文件夹的文件夹中运行它不能运行