[英]include all js files under a folder in jsp
Can we include all js files in one folder in jsp page. 我们可以将所有js文件包含在jsp页面的一个文件夹中吗? For example i had a folder name with ABC and js files under it is a.js, b.js and c.js.Instead of including js files individually in jsp page
例如我有一个文件夹名称,其中包含ABC和js文件,分别是a.js,b.js和c.js,而不是在jsp页面中单独包含js文件
<script type="text/javascript" src="<%=request.getContextPath()%>/ABC/a.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/ABC/b.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/ABC/c.js"></script>
can we do like below format ??? 我们可以喜欢下面的格式吗?
<script type="text/javascript" src="<%=request.getContextPath()%>/ABC/*.js"></script>
I mean i need to include all 3 js files in jsp page. 我的意思是我需要在jsp页面中包含所有3个js文件。 can anyone help?
有人可以帮忙吗?
Something like this should work: 这样的事情应该起作用:
<%
for(File f : new File(request.getContextPath() + "js").listFiles()){
if(f.getName().endsWith(".js")){
out.println("<script src='js/" + f.getName() + "' type='text/javascript'></script>");
}
}
%>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.