aspose file tools*
The moose likes Spring and the fly likes Strange STS behavior in the creation of Spring MVC project using STS template help, wrong URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Strange STS behavior in the creation of Spring MVC project using STS template help, wrong URL" Watch "Strange STS behavior in the creation of Spring MVC project using STS template help, wrong URL" New topic
Author

Strange STS behavior in the creation of Spring MVC project using STS template help, wrong URL

Andrea Nobili
Greenhorn

Joined: Nov 08, 2012
Posts: 21
I am quite new in the Spring MVC world and I have a doubt about the corretct creation of a Spring MVC project.

When I run an imported project (for example the Spring MVC Showcase example downlodable form the STS dashboard), inside the browser URL bar this project have an URL like: http://localhost:8080/project-name/

For example the Web MVC Showcase example have project name: "spring-mvc-showcase" and have the following URL: for example the Web MVC Showcase example have project name: "spring-mvc-showcase" and have the following URL: http://localhost:8080/spring-mvc-showcase/

Now, my doubt is related to the creation of a new Spring MVC project using Spring Template in STS\Eclipse.

I do the following operation inside STS:

File --> New --> Project and appears to me a wizard where I can chose the type of project.

So I chose Spring Template Project, now appears to me ano other wizard windows where I can chose the specific typology of Spring Project and I chose "Spring MVC Project"

Ok, now appears to me an other wizard windows in which I have to set up:
Project name and I insert: my-spring-project
Top level package and I have insert: org.mycompany.foo

Ok, now I run my project on server, this don't run and inside the URL bar of the browser I have not http://localhost:8080/my-spring-project/ (as I would expect) but I have: http://localhost:8080/foo/

In the stacktrace I have the following error message:

WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/foo/] in DispatcherServlet with name 'appServlet'

Then if I do a project clean of my project, STS rebuild the project and if I try to run it again the project run well and the URL address still remain: http://localhost:8080/foo/

I think that this is a strange behavior and I have not ideas what is the reason about it...

So:

1) Why the URL is not http://localhost:8080/my-spring-project/ but is http://localhost:8080/foo/ ?

2) Why I have to clean and rebuild my project to run it?

3) I am doing some error in the creation of a standard Spring MVC project?

I am going crazy...

Thank you very much

Andrea
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1672
    
    7

Click your server in your servers are and select the module tab. It should show you your deployed application. Look at the path, this is your context root. You need to type you context root followed by whatever you have mapped. So if you have a request mapping with a value of "/foo" you would go to http://localhost:8080/my-context-root/foo


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange STS behavior in the creation of Spring MVC project using STS template help, wrong URL