When I create a Spring MVC Template Project with the SpringSource IDE, I run the application and the root URL is set as the last word of the default package name:
For example, when I create the project, I set the default package as com.sample.myapp. When I run the application, it opens at http://localhost:8080/myapp. Why does the root URL not use my project name, MyProject, instead?
This is a problem because I have to specify all of the URL’s in my application to /myapp/resources/css/mycss.css but when I export a .war and deploy it to a Tomcat server, then Tomcat expects the project name instead (it wants me to use /MyProject/resources/css/mycss.css. As a result, all of my links are broken when I deploy (but not when I run on tomcat locally within the SpringSource IDE…)
Has anyone else run into this problem?
Example for comment discussion below:
<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
<property name="service"
value="https://localhost:8443/MyProject/j_spring_cas_security_check" />
<property name="sendRenew" value="false" />
</bean>
It depends on how you run the application. I assume you chose “Run on Server” from within the SpringSource IDE (STS)? If you double click on the server definition in STS, you will see a “modules” tab. From there, you can edit the “Path” and set it to whatever you want. When you select “Run on Server”, STS has to define a context path and simply defaults it to last element of the default package. If I recall correctly, by default Tomcat uses the file name name of the zipped or exploded .war. In either case, you can over-ride it.
Hope that helps.