Sorry in advance if this is something trivial
In ASP.NET I remember you could direct your routes to
<a href="~/User/Login">Login</a>
and you didn't have to worry about anything URL related (if your project is on localhost:1234
or localhost:1234/myproject/
or whatever), ASP.NET would do the job for you.
Is there an equivalent for that in Spring. Currently when I start up my project, using GlassFish, it starts up at url localhost:8080/myproject
and the resources (css, js...) aren't even being loaded until I add another /
in the end (localhost:8080/myproject/
).
All my routes are on the first URL parameter and my GET variables aren't even RESTful, simply because if I go one /
more, my routing is going to go wrong, ie.
<a href="/home">Home</a> //will go to localhost:8080/home (not the project scope)
<a href="home">Home</a> //is fine until I go to another / in url...
//...(/foo/bar), then it goes all the way up
//to localhost:8080/foo/home
I tried to google this, but every time I try to google something equivalent to ASP.NET, I just get a lot of ASP.NET tutorials (nothing Spring related).
So.. is there any way to keep the url consistent, something in the lines of:
<a href="~/user/login">Login</a>
or
<a href="${ projectUrl }/user/login">Login</a>
How is it normally done in (commercial) applications? What's the best practice in this?