- This topic has 3 replies, 2 voices, and was last updated 13 years, 5 months ago by support-swapna.
-
AuthorPosts
-
DavidMemberI have a tomcat application that will rely heavily on css/js. Unfortunately, I can’t seem to get my stylesheets picked up in tomcat, but they are in Eclipse. here is my dir structure (edited for brevity):
project
|-src
|-webapp
|– WEB-INF
|—css
\—default.css
|—javascript
Here is my html:<!DOCTYPE html> <html> <link href="WEB-INF/css/default.css" rel="stylesheet" type="text/css" /> <div id="header"> <h1> Office Name </h1> </div> <div id="navigation"> <ul> <li> <a href="#">Home</a> </li> <li> <a href="#">About</a> </li> <li> <a href="#">Services</a> </li> <li> <a href="#">Contact us</a> </li> </ul> </div> <div id="aside"> <h3> Aside heading </h3> <p> Various menu choices go here </p> </div> <div id="content-container"> <div id="content"> <h2> Page heading </h2> <p> paragraph one </p> <p> paragraph two </p> <p> paragraph three </p> </div> </div> </div> <div id="footer"> Copyright © me, 2011 </div> </html>
But it feels like the web.xml is not allowing the css or js files thru. So here it is:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name>project</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <servlet> <servlet-name>project</servlet-name> <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.project.resources</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>project</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>
Any ideas?
support-swapnaModeratorsonoerin ,
Can you try placing the CSS files under the WEBROOT folder instead of WEB-INF folder?
Let us know how it works for you.
DavidMemberI moved my css/default.css under webapp/ and it was still not picked up. When I try and view the css directly in the browswer with “css/default.css” I get a 404.
support-swapnaModeratorsonoerin ,
Your directory structure is different from MyEclipse directory structure. So you will have to create a new web project in MyEclipse and copy the files of your Eclipse project to the corresponding folders to be able to work with MyEclipse.
I suggest you create a new Web project in MyEclipse IDE and place the CSS files in the WEBROOT folder of the project. This should fix the issue.
Here is a tutorial on web projects in MyEclipse which will help you :
http://www.myeclipseide.com/documentation/quickstarts/webprojects/Let us know how it works for you.
-
AuthorPosts