这是我的jsp文件。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="js/scripts.js" type="text/javascript"></script>
<title>error</title>
</head>
<body>
No user found
</body>
</html>项目文件结构如下:

这是我在浏览器中单击查看页面源代码时所看到的内容
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>error</title>
</head>
<body>
No user found
</body>
</html>scripts.js中的代码是
alert("hello");帮我一把……无法检测脚本标记。当在html页面中使用相同的代码时,这是可以正常工作的,问题只出现在jsp页面上。
谢谢。
发布于 2016-08-31 13:32:39
<script src="${pageContext.request.contextPath}/js/scripts.js"/>使用${pageContext.request.contextPath}。
发布于 2016-08-31 13:24:58
以前没怎么用过JSP,但看起来像是路径问题。您有没有尝试过/js/scripts.js或./js/scripts.js,或者如果您在某个地方定义了某种静态资源路径,<ASSETS_PATH>/js/scripts.js
发布于 2016-09-27 14:12:50
从jsp到js的路径是否在父目录的子目录中?如果是这样,请尝试将脚本标记更改为:
<script src="../js/scripts.js" type="text/javascript"></script>https://stackoverflow.com/questions/39241328
复制相似问题