2

我们使用 JOSSO 框架进行单点登录。它在 Spring 2.5.6 中正常工作。在 Spring 3 中似乎引入了严格的 XML 模式验证,JOSSO XSD 很长时间没有更新,因此我们在服务器启动期间出现错误。有什么方法可以在 Spring 3 中禁用模式验证(可能使其类似于 2.5.6)..

4

1 回答 1

4

我还没有尝试过,但是 GenericXmlApplicationContext 有一个 setValidating(boolean validating) 方法。

我相信您可以使用此方法来停用验证:

GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.setValidating(false);
context.load("myResource.xml", "otherResource.xml");
context.refresh();

https://jira.springframework.org/browse/SPR-5014

如果您在 Web 应用程序中使用 spring,那么设置验证参数会更加困难。我能想到的一种方法是,基于 ContextLoader 使用 web.xml 上下文参数“ contextClass”来指定上下文类(默认为:)org.springframework.web.context.support.XmlWebApplicationContext

  • @see:org.springframework.web.context.ContextLoader
  • @see:org.springframework.web.context.ContextLoader#determineContextClass(ServletContext)

也许您可以创建一个禁用验证的 XmlWebApplicationContext 的子类,并使用“ contextClass”参数来加载此类而不是 XmlWebApplicationContext。

于 2010-11-15T12:56:34.463 回答