Reputation: 58863
I have zero knowledge about Tomcat and I only need to have it working for some testing, so please forgive me if the questions is stupid.
I deployed a .war archive in Tomcat 7.0.22 (Java 1.6, MacOS Lion). The war is called "myapp.war" and so Tomcat is serving http://localhost/myapp
(having expanded the war in /webapps/myapp). I'm fine with this.
Whenever I visit "http://localhost/myapp
" the page won't load static files (eg: for either /core.css
or core.css
it looks for "http://localhost/core.css
") while "http://localhost/myapp/
" ( <-- note the slash!) works and serves http://localhost/myapp/core.css
.
My web.xml:
<web-app>
<servlet>
<servlet-name>org.github.pistacchio.deviantchecker.core/app servlet</servlet-name>
<servlet-class>org.github.pistacchio.deviantchecker.servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>org.github.pistacchio.deviantchecker.core/app servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
How to set this up properly? Thank you
Upvotes: 0
Views: 285
Reputation: 743
If you only need it working for testing purposes the easiest solution might be to add a base html tag to the head of your webpage.
<base href="http://localhost/myapp/" />
should do the trick.
See this link for further explanation of the base tag
Upvotes: 1