简体   繁体   中英

Absolute path in a web app

This may sound like a dumb question.

I received a (basic) web application developed by another person, using HTML and JavaScript . In this application he used his JavaScript file path as /javascripts/_FileName_.js . But when I tried to run it on a Tomcat (8.5) server, those JavaScript files didn't executed. But when I changed the path to javascripts/_FileName_.js (Without the / at the beginning), it worked fine.

This application was already ran in a server and it worked fine. What has to be the problem here ?

as @duffymo described in comments, the leading slash tells tomcat to start looking for that file at the root of the application context, which is the webapps folder in tomcat. But if we remove that leading slash , it searches for the file from the current folder.

That was the problem. I am posting this as an answer because he mentioned these in comments only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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