簡單紀錄一下Google App Engine 中使用struts 2的方法
詳細圖示教學參考下列連結:
1.加入struts所需要的一些基本library
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.1.jar
freemarker-2.3.13.jar
ognl-2.6.11.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jar
2.建立ognl listerner,將 OgnlRuntime的SecurityManager設定為null,listener內容如下:
package util.listener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import ognl.OgnlRuntime;
/**
* 建立ognl listener **
*/
public class InitListener implements ServletContextListener,
HttpSessionListener, HttpSessionAttributeListener {
public InitListener() {
}
public void contextInitialized(ServletContextEvent sce) {
OgnlRuntime.setSecurityManager(null);
}
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
public void sessionCreated(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
}
public void sessionDestroyed(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
}
public void attributeAdded(HttpSessionBindingEvent arg0) {
// TODO Auto-generated method stub
}
public void attributeRemoved(HttpSessionBindingEvent arg0) {
// TODO Auto-generated method stub
}
public void attributeReplaced(HttpSessionBindingEvent arg0) {
// TODO Auto-generated method stub
}
}
再於web.xml中加入listener
com.jun.util.listener.InitListener
沒有留言:
張貼留言