castor Mapping 的问题
问一个问题,castor的Mapping,
mapping = new Mapping();
mapping.loadMapping(mapFilePath);
这里的mapFilePath应该是什么样子的。我用"classes/xmltest/mapping.xml"这个文件,但是却报错,说无法找到文件。但是文件确实在
WEB-INF/classes/xmltest/mapping.xml啊。
而且,用来存放数据的test.xml却能够被正常处理,实在想不通
源代码如下
public UserDictModule read() throws Exception {
UserDictModule module = null ;//自己定义的类
try {
mapping = new Mapping();
mapping.loadMapping("classes/xmltest/mapping.xml");
File file = new File("classes/xmltest/test.xml");
Reader reader = new FileReader(file);
Unmarshaller unmarshaller = new Unmarshaller(mapping);
module = (UserDictModule) unmarshaller.unmarshal(reader);
}
catch (Exception e) {
e.printStackTrace();
throw e;
}
return module;
}