1

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?

4

1 回答 1

1

如果你把一个文件放在/resources它下面,它会以my-project.war/my-project.war/WEB-INF/classes/. 这是你的classpath中的事情。相反,您应该将 css 文件放在/webapp. 这将使他们陷入困境my-project.war/。这些文件现在可以直接访问了

http://localhost:8080/test.css
于 2013-06-20T17:27:31.270 回答