html - Eclipse static web project HTTP Preview/Server module conflicts with relative paths -


so start static web project on eclipse. let's mysite. , start jetty web server on eclipse , open localhost:8080 on browser.

this i'll see:

main http preview page

so go localhost:8080/mysite/index.html , see homepage.

home page

as can see the link not leading should be. should going localhost:8080/mysite/index.html, or more preferable, mysite's index page should hosted on localhost:8080/index.html , not on module.

index.html

<!doctype html> <html lang="en">     <body>         <a href="/index.html">home</a>     </body> </html> 

if change mysite/index.html defeats purpose of being http preview server, because mysite it's own site , not kind of module.

how fix without using workaround?

as can see the link not leading should be. should going localhost:8080/mysite/index.html, instead goes localhost:8080/index.html

that because using url form relative server's root /.

simply use ./(page-relative path) instead of /(server-root-relative path) in mysite/index.html.

<!doctype html> <html lang="en"> <body>     <a href="./index.html">home</a> </body> </html> 

hope helps!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -