I have an application using spring framework using maven project. I also have an css and js under WEB-INF folder. When i try to call the javascript and css like this:
<link rel="stylesheet" href="../allDesign/js/vendor/animsition/css/animsition.min.css">
I can open the url to open via project, but when i try to run, i get an error that the browser can't find the source code.
the error show like this :
Here our structure of my project:
can you tell me how to fix the url?, because when i try to click the url on netbeans, netbeans can find my animsition.min.css.
Files in the WEB-INF and META-INF folder are protected, you can not access them directly.
So move your allDesign as a direct subfolder of Web Packages.
Related
I have an angular app, to this I am trying to add an npm package called svgedit. It gets installed. But when I try to reference a java-script file it says
net::ERR_ABORTED 404 (Not Found)
This is how I am trying to reference it in my index.html in the head section,
<script type="module" src="node_modules/svgedit/svgedit-config-es.js"></script>
I can access this file from within vs code by clicking "ctrl + left mouse". It opens the file properly meaning the reference is proper. But when it runs it gives the above mentioned error in the console. I have also tried switching the type attribute to "text/javascript".
Basically I am trying to integrate this package in my angular app. What is the correct method to go about it.
ng serve will only serve compiled files from your src directory and what''s in the assets folder. It will not serve node_module files directly.
The usual way to add scripts it to add it to the scripts section in angular.json
scripts:
[ //other scripts
"node_modules/svgedit/svgedit-config-es.js"
]
Is your html page in the root directory of your project? if not make sure to navigate to the file correctly. if the html page in the root directory of your project then there must be a typo in the src
Basically I am trying to integrate this package in my angular app. What is the correct method to go about it.
The right way to go about it is to use a bundler like webpack, rollup etc...
I am going to be working on an angular project without internet access, so my links to the cdn will not function. I would like to save the angularjs library to a folder inside of my project. Here is what I have tried:
I went to the cdn link, copied all of the text, pasted it into a file, and saved that file as angular.min.js . I then commented out the script tag for the cdn in my index.html file, and put in a new script tag specifying the path to the new saved file. When I open my project, I get the error "Uncaught ReferenceError: angular is not defined."
Here are the relevant pieces of my project's file/folder structure:
project
|_core
| |_public
| |_app
| |_index.html
|_libraries
|_angular.min.js
And here is my script tag:
<script src="./../../../libraries/angular.min.js"></script>
And here is the link to the cdn from which I copied the text:
https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js
Are you using a local webserver of any kind? Angular and many scripts need to be loaded from http and not file://. For this, you could use python's SimpleHTTPServer: python -m SimpleHTTPServer 8080 -- will open an http server on http://localhost:8080, open the url in your browser and you should be good to go. Also note that the order in which you load the scripts in your HTML is important, and Angular needs to be loaded before all modules of code that use it.
<script src="../../../libraries/angular.min.js"></script>
How about this ?
Have you just tried this?
<script src="/libraries/angular.min.js"></script>
Maybe your server start website (localhost:80) from the root of your project
You can use Grunt task to minify and concatenate all files. You can read the docs of GruntJS. Very useful.
http://gruntjs.com/sample-gruntfile
see the concatenate section.
if you do that manually you have check the sequence of lib files. Angularjs lib need to be on top.
There are chances of errors.
yes just to include a file you don't need Grunt
check in chrome inspect developer tool in network tab if your file angular.min.js loaded properly. If not you can change the path and try but if it is loading and still you are getting same error so please create jsfiddle or plunker of your file so that we can look it in detail.
i have downloaded a foreign web solution from my clients httpdoc folder.
Now i need to edit them in Visual Studio 2013/2015 but i dont know how to integrate them.
their htdocs files and folders;
global.asax
package.config
web.config
gruntfile.js bower.json
package.json
./app/components/account/
logincontroller.html
login.js
register.html
registercontroller.js *and some more......)
./app/components/home/
indexcontroller
index.js
and some more......)
./app/components/shared/
headercontroller.js
header.html
more file like this......)
./app/components/
... and more folders
./app/services/
ajaxService.js
services.js and
..a lot more .js files)
./app/vendors/
angular, bootstrap, jquery stuff)
./bin/
EntityFramework.dll
System.web.razor.dll
...and more dll's
For me this looks MVC like, but with a folder structure i do not understand
However, i need to edit, debug and run the sources in VS and i have no idea how to include it. Do i need to create a simple project (type?) and copy and paste or how would this work.
Can you please advice me?
I am not sure if I understand your question but I am guessing you have an ASP.NET MVC project using AngularjS. Right click the path from your existing project on Solution Explorer and add existing files.
Warning: You might need to include dll files as well.
I agree with mason. Probably should just add the files to an existing project.
Looks like an Angular SPA. May have no .Net aspect to it (i.e. VS just used as an editor). Just copy the files into a new VS project. If it has compiled code associated with it, it will be hard to reproduce the .Net code.
normally I would go
<script src="~/Scripts/Controls/SomeScript.js"></script>
and this finds SomeScript.js in the "Scripts/Controls" folder of the same project that the ASP.NET .cshtml page is in.
The time has come however to share the javascript file between two projects. I need to move it to a library project.
What would the value of the src attribute have to be to locate the javascript file in a completely different project in the same solution? Do I have to do something else? How is this problem usually solved?
I have tried "Copy to output directory" on the "SomeScript.js" properties page and this copies the script and its containing folder to the 'bin' directory. However chrome reports "Not allowed to load local resource" when trying to access .js files in the bin folder.
The folder which your scripts exist must be within the project tree, especially if you are planning on publishing the app to a remote server. Visual Studio provides an option to Add Existing Items as a link, which would allow you to symlink items stored outside your project tree into a folder within your project tree. Any changes to the original file will be reflected in your project; however if the file is deleted, the link will remain, broken.
You must also add the following to the end of the project .csproj file before the Project close tag.
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)" DestinationFiles="%(Content.Link)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" Condition="'%(Content.Link)' != ''" />
</Target>
This edit to the .csproj file will cause visual studio to actually copy the linked file to the location of the link at the end of the build.
In this way, you can still reference ~/Scripts/Controls/SomeScript.js in your project.
use this reference to resolve your issue: Server.MapPath("."), Server.MapPath("~"), Server.MapPath(#"\"), Server.MapPath("/"). What is the difference?
seems that the best way would be to use / at the beginning - that is the root directory.. you can manage your way down from there
I'm attempting to build my first phonegap application using the phonegap build cloud compiler. In the instructions there it says to remove phonegap.js before uploading... Where is this mystery file? I downloaded the latest phonegap and nothing in the /Libs/ looks right. There seems to be no documentation on how to setup your root HTML page properly to be compiled with phonegap.
"Once you've included the necessary assets, remove the phonegap.js (cordova.js) as Build will automatically inject it during compile time." - https://build.phonegap.com/docs/preparing-your-app#what_do_i_upload
I'm under the impression that I just need to use the JS API for code completion and then let the cloud compiler do its work, but all the documentation revolves around installing an SDK for each platform. I don't want to use xCode or eclipse-- I just want to write javascript.
What is the bare minimum resources I need to include on my root HTML file?
What is the bare minimum resources I need to include on my root HTML
file?
You need just 2 files: index.html (may be the name "index.html" is configurable in the config.xml, I am not sure) and config.xml.
Here is a starter app: https://github.com/phonegap/phonegap-start, take a look in the www folder.