0

I have one controller for registration form i.e. RegisterController. for that my URL is like this

http://localhost:8050/lifejodi-web/register/formStep1

but when i create new controller called ProfileController , to see my profile for that my URL should be like

http://localhost:8050/lifejodi-web/profile/myProfile

but it takes URL as a

/lifejodi-web/register/profile/myProfile

can anyone give me solution for that.

user1523
  • 19
  • 4

1 Answers1

0

The link in an HTML is relative to the current request URL (as you see in browser address bar), not to the server side URL. So you should specify either complete path or relative path that should match with the controller URL.

You can set path relative to the webapp context(the "AppName" part).

You could get the context path using ${pageContext.request.contextPath}.

Example:

<body>
    <a href="${pageContext.request.contextPath}/profile/myProfile">link</a>
</body>

If you want to set a base path for all relative links so that you don't need to repeat ${pageContext.request.contextPath} in every relative link, use the <base> tag.

You can check this SO

Community
  • 1
  • 1
Shaheer
  • 1,593
  • 1
  • 13
  • 14