2017-07-16 47 views
0

`我已經在web內容中直接添加了css文件夾,並且已經在spring.xml中進行了映射。但CSS沒有加載

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:cache="http://www.springframework.org/schema/cache" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.0.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/cache 
     http://www.springframework.org/schema/cache/spring-cache-3.2.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> 

    <context:component-scan base-package="com.homebanking" /> 
    <mvc:annotation-driven/> 
    <context:annotation-config /> 
    <mvc:resources location="/css/*" mapping="/css/*"/> 
    <mvc:resources location="/js/*" mapping="/js/*"/> 


    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/WEB-INF/jsp/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 

    <bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
     <property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
     <property name="url" value="jdbc:mysql://localhost:3306/homebanking" /> 
     <property name="username" value="root" /> 
     <property name="password" value="root" /> 
    </bean> 

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 

     <property name="dataSource" ref="dataSource"/> 
     <property name="packagesToScan" value="com.homebanking.model"/>  
     <property name="hibernateProperties"> 
      <props> 
       <prop key="dialect">org.hibernate.dialect.MySQLDialect</prop> 
      </props> 
     </property> 
    </bean> 
</beans> 

`

我已經使用MVC映射css文件中彈簧servlet.xml文件:資源標記。但是css沒有加載。我把css文件夾中的網頁內容

<mvc:resources location="/css/*" mapping="/css/*"/> 
<mvc:resources location="/js/*" mapping="/js/*"/> 

請幫我out.it是以前工作的罰款。但突然css沒有加載。

+0

你能告訴我你的文件夾結構,以及XML文件請 –

+0

我無法添加我的文件夾結構 – Yuvanath

+0

的PIC我已經直接放在WebContent文件夾下的css文件夾 – Yuvanath

回答

0

如果你都放置在web內容你的CSS文件夾中,你需要指定你這樣的資源:

<mvc:resources mapping="/css/**" location="/css/" /> 

,那麼你可以導入你的CSS文件,像這樣:

<link href="<c:url value="/css/youMain.css" />" rel="stylesheet"> 
+0

我改變,因爲你說..現在它工作..感謝很多:) – Yuvanath

相關問題