类型未解析
问题内容:
我正在尝试构建可在此处链接获得的mvc-showcase示例。
但是我收到以下错误:
cvc-complex-type.2.4.c:匹配的通配符很严格,但是找不到元素’resources’的声明。
的源代码servlet-context.xml
是
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven conversion-service="conversionService" />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<!-- Imports user-defined @Controller beans that process client requests -->
<beans:import resource="controllers.xml" />
<!-- Only needed because we install custom converters to support the examples in the org.springframewok.samples.mvc.convert package -->
<beans:bean id="conversionService" class="org.springframework.samples.mvc.convert.CustomConversionServiceFactoryBean" />
<!-- Only needed because we require fileupload in the org.springframework.samples.mvc.fileupload package -->
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
</beans:beans>
注意: 我正在使用Eclipse IDE,并且正在使用spring
3.0.4版本(因为我使用的是项目链接中给出的相同pom.xml )
问题答案:
不幸的是,我似乎无法在Eclipse 3.6中实现它。但是我在Spring Tool Suite
v2.5.0.M3(http://www.springsource.com/products/springsource-google-
download)中得到了解决-如果您检查其XML
Catalog,它们实际上是数十个条目,可能会否定在STS上使用香草Eclipse的价值。如果您正在学习Spring,但是由于缺少入门文档而感到困惑,则可以尝试使用Spring
Roo(我个人使用该工具来启动Spring MVC项目),以后可以根据需要将其禁用。
观看MVC Showcase视频(http://s3.springsource.org/MVC/mvc-showcase-
screencast.mov),该视频显示了将MVC
Showcase加载到STS中。请注意,似乎唯一可以修复Eclipse错误的版本(运行时随处都可以使用)是v2.5.0.M3-只需确保将签出展示代码签入该STS版本的新工作区即可。
希望这可以帮助。