【问题标题】:Spring serving static content with mvc:resources, invalid xsdSpring 使用 mvc:resources 提供静态内容,xsd 无效
【发布时间】:2011-04-19 06:23:10
【问题描述】:

根据http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources 的建议,我希望使用<mvc:resources> 来提供我的spring 静态内容。

我尝试了以下 XML,但 .xsd 文件不包含 <mvc:resources> 的声明,并且我找不到替代 .xsd。我可以忽略 eclipse 错误,但由于 SAXParseException,服务器不会启动。

我哪里出错了?

<?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>

【问题讨论】:

  • 我想你可能已经通过了这个链接..stackoverflow.com/questions/3769888/… 我能够使用maven tomcat:run 部署应用程序,尽管它在 eclipse 中显示错误
  • 这些双精度 ** 在映射 (/css/**) 中表示什么。据我了解,只需要一个 * 来包含它之后的所有内容吗?

标签: spring spring-mvc


【解决方案1】:

&lt;mvc:resources&gt; 中的属性是在 Spring 3.0.4 中添加的。

编辑 也就是说:您只需将 Spring 3.0.4 添加到您的依赖项中,一切正常(Eclipse 插件中的错误标记除外)。在运行时配置文件由 Spring 自己解析,因此使用 Spring 内置的 XSD 文件。

【讨论】:

【解决方案2】:

不比axtavt 的响应好,但是关于如何抑制Eclipse 错误的一点线索。进入项目属性,然后Spring→Beans Support→Load NamespaceHandlers and XSDs from project's classpath [experimental]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-14
    • 2019-10-20
    • 1970-01-01
    • 2020-06-26
    • 2011-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多