I have created a simple maven web app
project:
mvn archetype:generate -DgroupId=com.stsd.project -DartifactId=my-project -Dversion=1.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
I want this project to be a simple Servlet
project integerated with maven
So I don't want to use spring-mvc
and so on.. wanna keep it as simple as possible.
I have all my resources including of css
files in my-project/src/main/resources
Now I want to link css
files to my front-ends.. but after deploying the project to a tomcat
server I can only see messy layout with no css style. I just wonder if I really need to have a servlet-context.xml
for this to see css
styles in front view?
If you put a file under /resources
it ends up in my-project.war/my-project.war/WEB-INF/classes/
. This is where things go in your classpath . Instead, you should put the css file under /webapp
. This will make them go under my-project.war/
. These files will now be directly accessible by going to
http://localhost:8080/test.css
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.