简体   繁体   English

将javascript文件包含到JSP文件中

[英]Include javascript file to JSP file

Anyone knows on how to include a .js file to a JSP file in java. 任何人都知道如何在Java中将.js文件包含到JSP文件中。 I can't use the script.js file in JSP. 我不能在JSP中使用script.js文件。 Below is the folder structure of the .js file. 下面是.js文件的文件夹结构。

+---src
|   \---main              
|       \---webapp
|           |   index.jsp  
|           +---js
|           |       script.js
|           |       
|           +---META-INF
|           |       context.xml
|           |       
|           \---WEB-INF
|                   web.xml

Thanks! 谢谢!

put this in the <head> along with your other JS includes and CSS. 将其与其他JS include和CSS一起放在<head> These types of includes work the same was as static HTML pages, there isn't anything special about your file being JSP in regards to this. 这些类型的包含工作与静态HTML页面相同,关于此,作为JSP的文件没有什么特别之处。

<script src="/js/script.js" type="text/javascript"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM