如果直接在webapp的classpath加入Struts2的相关jar,Struts2是不能正常工作的。现在安一下办法就可以了:
1.首先写这样一个类:
package com.ociweb.gaestruts2;
// imports
public class InitListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {
public InitListener() {
}public void contextInitialized(ServletContextEvent sce) {
OgnlRuntime.setSecurityManager(null);
}
// … all other methods stubbed out to do nothing
}
2.在web.xml中加入如下代码:
com.ociweb.gaestruts2.InitListener
我已经验证过了。原文出自Google Group。