I am new to J2EE and Web development. Here is my issue: I want to include angular.js in the webpage.
Here is the version that works:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src=".2.1/angular.min.js"></script>
<title>Lets Meet Up!</title>
</head>
But I also want to have some local javascript files, and hopefully, I want to import the angularjs in the local directory
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="WEB-INF/lib/angular/angular.js"></script>
<title>Lets Meet Up!</title>
</head>
The the page is unable to run the javascript.
My stack is Tomcat, Spring MVC, Spring, J2EE I put the angularjs source in AppRoot/WebContents/WEB-INF/lib/angular
Anyone can help? THanks!!
I am new to J2EE and Web development. Here is my issue: I want to include angular.js in the webpage.
Here is the version that works:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="http://code.angularjs.org/1.2.1/angular.min.js"></script>
<title>Lets Meet Up!</title>
</head>
But I also want to have some local javascript files, and hopefully, I want to import the angularjs in the local directory
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="WEB-INF/lib/angular/angular.js"></script>
<title>Lets Meet Up!</title>
</head>
The the page is unable to run the javascript.
My stack is Tomcat, Spring MVC, Spring, J2EE I put the angularjs source in AppRoot/WebContents/WEB-INF/lib/angular
Anyone can help? THanks!!
Share Improve this question edited Nov 4, 2016 at 21:51 George Kagan 6,1248 gold badges49 silver badges50 bronze badges asked Nov 16, 2013 at 0:31 BersaKAINBersaKAIN 2972 gold badges3 silver badges11 bronze badges 1- One sub question here , will that internet based script tag <script src="code.angularjs.org/1.2.1/angular.min.js"></script> Work in remote deployed server that is without internet connection ? – rinilnath Commented Sep 15, 2021 at 14:17
2 Answers
Reset to default 11Files in WEB-INF
are inaccessible.
Put angular.min.js
and all other static assets at the top level of your war file. Or better yet in some nice folder like js/angular/angular.min.js
at the top level.
Then do this
<script src="js/angular/angular.min.js"></script>
Depending on your needs you might want to consider serving your assets from a CDN, but that's another story altogether.
Don't put them into WEB-INF, that folder is for the stuff that you do not want to have directly served.
Put it next to WEB-INF
+- WEB-INF
+- static