1 Reply Latest reply: Apr 30, 2014 10:58 AM by Kosta-Oracle RSS

    Using Css styles with Spring MVC (Libraries 3.2.7)

    Huron


      Hello.

       

      I am not sure if i am in the correct section or forum, and is better i try in forum of Spring.

       

      My problems is that i dont get use Css styles in my JSP. I am using like IDE, NetBeans 8, 64 bits, and the last version of JDK.

       

      My css with the styles is the url in my project: WEB-INF/resources/style.css

       

      This is a copy of my dispatcher.xm:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <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:aop="http://www.springframework.org/schema/aop"
             xmlns:tx="http://www.springframework.org/schema/tx"
             xmlns:context="http://www.springframework.org/schema/context"
             xmlns:mvc="http://www.springframework.org/schema/mvc"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
             http://www.springframework.org/schema/context
             http://www.springframework.org/schema/context/spring-context-3.1.xsd
             http://www.springframework.org/schema/mvc
             http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">


      <context:component-scan base-package="org.ecoaldea.controller" />
      <mvc:annotation-driven />
      <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

      <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/style.css" />



      <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" p:order="0" />


      <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
      <property name="defaultLocale" value="es"/>
      </bean>

       

      <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>

             
         
          <!--
          Most controllers will use the ControllerClassNameHandlerMapping above, but
          for the index controller we are using ParameterizableViewController, so we must
          define an explicit mapping for it.
          -->
         
       
         
          <!--
        
          <bean class="org.ecoaldea.controller.Homecontroller" id="controladorDatosUsuario"/>

          -->   
         
          <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
              <property name="mappings">
                  <props>
                      <prop key="index.htm">indexController</prop>
                    <!--
                      <prop key="prueba.htm">controladorDatosUsuario</prop>
                      -->
                  </props>
              </property>
          </bean>

          <bean id="viewResolver"
                class="org.springframework.web.servlet.view.InternalResourceViewResolver"
                p:prefix="/WEB-INF/jsp/"
                p:suffix=".jsp" />

          <!--
          The index controller.
          -->
         
                    
          <bean name="indexController"
                class="org.springframework.web.servlet.mvc.ParameterizableViewController"
                p:viewName="index" />

      </beans>

       

       

       

       

      And in my JSP.page, i am trying use the CSS style without seccess using diferent methods:

       

      <img src="/EcoAldeaSpring/WEB-INF/resources/images/Valle.png" alt="Example pic" style="border: 3px solid #ccc;" />

      <img src="<jstl:url value="/resources/style.css"/>"

      <img src="<%=request.getContextPath() %>/resources/images/Valle.png"></a>

      <link href="resources/style.css" rel="stylesheet">

       

      When i run my project, the web work fine, but in white etc, without my CSS.styles.

       

      Any help?.

       

      Thank you.