spring - My css files don't get loaded -
i'm going crazy why css file isn´t getting loaded. i'm using spring mvc 4
+ apache tomcat 8
i use same code other projects , works normally.
here's project structure
web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="webapp_id" version="3.1"> <display-name>ao</display-name> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <context-param> <param-name>contextconfiglocation</param-name> <param-value>hibernate.xml</param-value> </context-param> <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>mvc-dispatcher-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
my servlet context :
<context:component-scan base-package="controller"/> <mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/pages/" /> <property name="suffix" value=".jsp" /> </bean>
when try load :
<link rel="stylesheet" type="text/css" href="${pagecontext.request.contextpath}/resources/css/welcome.css" >
or
<link rel="stylesheet" type="text/css" href="/resources/css/welcome.css">
or
<link rel="stylesheet" type="text/css" href="/ao/resources/css/welcome.css">
i got error:
get http://localhost:8080/ao/resources/css/welcome.css 404 (introuvable)
try adding <mvc:default-servlet-handler /> mvc configuration file.
Comments
Post a Comment