java - cannot load css and js files when using spring mvc -


i new spring mvc. loading resources have use < mvc:resources mapping="/design/**" location="/design/" />. although worked well, not. cannot understand problem. can me?

here spring-dispatcher-servlet.xml. resource(design) folder in webcontent , has sub folders called css, js , images.

< beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd"> <context:component-scan base-package="controller"/>   <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix">         <value>/</value>     </property>     <property name="suffix">         <value>.jsp</value>     </property> </bean>   <bean id="viewresolverhtml" class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix">         <value>/</value>     </property>     <property name="suffix">         <value>.html</value>     </property> </bean>   <bean id="mongo" class="org.springframework.data.mongodb.core.mongofactorybean">     <property name="host" value="localhost"/> </bean>  <bean id="mongotemplate" class="org.springframework.data.mongodb.core.mongotemplate">     <constructor-arg name="mongo" ref="mongo"/>     <constructor-arg name="dabasename" ref="testdb"/> </bean>  <mongo:repositories base-package="model"/>  <mvc:view-controller path="/" view-name="index"/> <mvc:resources mapping="/design/**" location="/design/" />  <mvc:annotation-driven/> 

and how load resources in index.jsp

<link rel="stylesheet" href="design/css/reset.css" type="text/css" media="screen"> <link rel="stylesheet" href="design/css/style.css" type="text/css" media="screen"> <link rel="stylesheet" href="design/css/grid.css" type="text/css" media="screen"> <script src="design/js/jquery-1.6.3.min.js" type="text/javascript"></script> <script src="design/js/cufon-yui.js" type="text/javascript"></script> <script src="design/js/cufon-replace.js" type="text/javascript"></script> <script src="design/js/kozuka_gothic_pro_opentype_300.font.js" type="text/javascript"></script> <script src="design/js/kozuka_gothic_pro_opentype_500.font.js"  type="text/javascript"></script> <script src="design/js/ff-cash.js" type="text/javascript"></script> <script type="text/javascript" src="design/js/jquery.easing.1.3.js"></script> <script type="text/javascript" src="design/js/tms-0.3.js"></script> <script type="text/javascript" src="design/js/tms_presets.js"></script> <script src="design/js/jcarousellite_1.0.1.js" type="text/javascript"></script> 

try of below :

with jstl tag c:url

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <link href="<c:url value="/design/css/reset.css" />" rel="stylesheet"> 

with spring:url

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <spring:url value="/design/css/reset.css" var="reset" /> 

without tags

<link href="${pagecontext.request.contextpath}/design/css/reset.css" rel="stylesheet" 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -