我已经将我的 GWT 应用程序组装为我在嵌入式 Jetty 中运行的战争文件-
String confFile = System.getProperty("configFilename");
config = new XMLConfiguration(configFilename);
Server server = new Server(8080);
WebAppContext webapp = new WebAppContext();
webapp.setAttribute("config", config);
webapp.setContextPath("/");
webapp.setWar("file.war");
server.setHandler(webapp);
server.start();
server.join();
我正在尝试在 GWT 服务器端代码中访问我的“配置”对象-
public class MyServiceImpl extends RemoteServiceServlet implements
MyService {
config = (XMLConfiguration) this.getThreadLocalRequest().getAttribute("config");
}
在这里,config 始终为空。
我究竟做错了什么?我已经尝试过 config =(XMLConfiguration) this.getServletContext().getAttribute("config");
,但这也不起作用-我收到错误-
org.apache.commons.configuration.XMLConfiguration cannot be cast to org.apache.commons.configuration.XMLConfiguration