1

Imported an example project to my workspace which URL, lets say, looked like this:

http://localhost:8080/Example/login

Then I copied example project, renamed/refactored until it worked. My question is, where I can change the URL string that follows localhost ? At the moment, the URL is still same, but I want mine to be like:

http://localhost:8080/MyProject/login

I must mention, that on "Run on server" when it is loaded, the automatic URL is: http://localhost:8080/Example/ ... the login part must be added manually and after that controller recognizes it.

It seems like, the name after localhost is taken from ProjectName, but I renamed it after copy. Is there in some document where the change is needed to make manually ?

Lucky
  • 16,787
  • 19
  • 117
  • 151
SeldomScheen
  • 41
  • 1
  • 7
  • if it is a maven project you need to change you project name in pom.xml and after that remove the app from your application server than redeploy it. – Ismail Sahin Jun 02 '16 at 07:03
  • It should be in the your `@Controller` function or `@RestController` where `@RequestMapping` is currently "Example". If this is not the case then it's probably due to the login and hence a spring security thing in which case you'll need to look at the security configuration java file – Roel Strolenberg Jun 02 '16 at 07:13

2 Answers2

3

Ask myself, answer myself. The answer is found here: How to change context root of a dynamic web project in Eclipse?

Firstly: Change Web project settings under Properties - Web Project setting - Context root if it is not already done

Secondly: After that under Server list: Right click on server and clean.

That should do it.

Community
  • 1
  • 1
SeldomScheen
  • 41
  • 1
  • 7
0

You did not mention which server you are using assuming tomcat goto server.xml file and change as follows put the context tag inside host tag

    <Context docBase="MyProject" path="/login">

refer to the reference of context tag for more https://tomcat.apache.org/tomcat-4.1-doc/config/context.html

Assuming you changed your project name to MyProject