4

As recommended by http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources I wish to use <mvc:resources> for serving my spring static content.

I have tried the following XML, but the .xsd file doesn't contain a declaration for <mvc:resources> and I cannot find an alternative .xsd. I can ignore the eclipse error, but the server won't start because of a SAXParseException.

Where have I gone wrong?

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

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

</beans>
Steve
  • 2,207
  • 6
  • 24
  • 35
  • I think you might have gone through this link..http://stackoverflow.com/questions/3769888/mvcresources-type-not-resolved I was able to deploy the application using `maven tomcat:run` though it was showing error in eclipse – javanoob Oct 01 '10 at 06:23
  • What does these double `**` denotes in mapping (`/css/**`) . According to my understand only single * is required to include everything coming after it? – Abhinav Oct 04 '13 at 12:37

2 Answers2

10

Attributes in <mvc:resources> were added in Spring 3.0.4.

EDIT That is: you just add Spring 3.0.4 to your dependencies and everything works fine (except error marks in Eclipse plugin). At runtime config files are parsed by Spring itself, therefore Spring's built-in XSD file is used.

axtavt
  • 239,438
  • 41
  • 511
  • 482
  • But there is only one .xsd for all of 3.0. So how can it ever compile properly? http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd – Steve Sep 30 '10 at 09:46
  • @Steve: Schema name and location remains the same, but the actual XSD file inside the Spring jars changes: https://src.springframework.org/svn/spring-framework/tags/spring-framework-3.0.4.RELEASE/org.springframework.web.servlet/src/main/resources/org/springframework/web/servlet/config/spring-mvc-3.0.xsd – axtavt Sep 30 '10 at 10:01
1

Not better than axtavt's response, but a little clue on how to suppress Eclipse error. Go into the Project properties and then Spring→Beans Support→Load NamespaceHandlers and XSDs from project's classpath [experimental]: Eclipse Spring Project Properties Screenshot

Doc Davluz
  • 4,154
  • 5
  • 30
  • 32