我想加载存储在以下位置的xsd文件:
/WEB-INF/myxsd.xsd
我将在我的控制器的动作中引用它,不知道如何做到这一点.
另外,由于我将一直引用这个,我可以加载一次而不是按照请求加载吗?
public String create() {
// load xsd file here
}
你使用相对路径还是完整路径?
更新
我已经有了这个代码需要xsd文件,我将根据模式进行验证.
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(schemaFile);
schemaFile是我需要帮助初始化的,看起来newSchema有一些重载(文件,URI等),但这是一个本地文件,所以有意义的文件是否正确?
Validator validator = schema.newValidator();
我需要帮助从我的/ Web-inf /文件夹加载这个xsd文件.