« Struts2 ognl中的#、%和$符号用法说明« »GAE(Google App Engine)上Java开发两条Tips »
GAE(Google App Engine)上使用Struts2

转载自:http://acheron.javaeye.com/blog/396567  

 

Google App Engine for Java

这里看GAE支持的java框架/技术/语言 列表

http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine

 

然后是让Struts2运行在gae上的方法

这里有2个相关资料

 http://groups.google.com/group/google-appengine-java/browse_thread/thread/19018b0317f27817/ec19c458bb15413b?lnk=gst&q=struts2#ec19c458bb15413b

 

http://www.nabble.com/Google-App-Engine-support--td22972179.html

 

只看下文也可以

使用Struts2时候报异常

WARNING: Caught OgnlException while setting property 'location' on type 
'org.apache.struts2.dispatcher.ServletDispatcherResult'. 
java.lang.IllegalAccessException: Method [public void 
org.apache.struts2.dispatcher.StrutsResultSupport.setLocation(java.lang.Str ing)] 
cannot be accessed. 
   at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:508) 
   at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:812)

 

SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception 
caught setting 'name' on 'class com.ociweb.gaestruts2.HelloAction: Error 
setting expression 'name' with value '[Ljava.lang.String;@24de7d'

 

解决方法:

1. 建class如下

Java代码 
  1. package com.jun.util.listener;  
  2.   
  3. import javax.servlet.ServletContextEvent;  
  4. import javax.servlet.ServletContextListener;  
  5. import javax.servlet.http.HttpSessionAttributeListener;  
  6. import javax.servlet.http.HttpSessionBindingEvent;  
  7. import javax.servlet.http.HttpSessionEvent;  
  8. import javax.servlet.http.HttpSessionListener;  
  9.   
  10. import ognl.OgnlRuntime;  
  11.   
  12. /** 
  13.  * 为了让Struts2能在AppEngine上运行,因此要在web.xml中添加这个监听 ** 
  14.  */  
  15. public class InitListener implements ServletContextListener,  
  16.         HttpSessionListener, HttpSessionAttributeListener {  
  17.   
  18.     public InitListener() {  
  19.     }  
  20.   
  21.     public void contextInitialized(ServletContextEvent sce) {  
  22.         OgnlRuntime.setSecurityManager(null);  
  23.     }  
  24.   
  25.     public void contextDestroyed(ServletContextEvent arg0) {  
  26.         // TODO Auto-generated method stub  
  27.     }  
  28.   
  29.     public void sessionCreated(HttpSessionEvent arg0) {  
  30.         // TODO Auto-generated method stub  
  31.     }  
  32.   
  33.     public void sessionDestroyed(HttpSessionEvent arg0) {  
  34.         // TODO Auto-generated method stub  
  35.     }  
  36.   
  37.     public void attributeAdded(HttpSessionBindingEvent arg0) {  
  38.         // TODO Auto-generated method stub  
  39.     }  
  40.   
  41.     public void attributeRemoved(HttpSessionBindingEvent arg0) {  
  42.         // TODO Auto-generated method stub  
  43.     }  
  44.   
  45.     public void attributeReplaced(HttpSessionBindingEvent arg0) {  
  46.         // TODO Auto-generated method stub  
  47.     }  
  48.   
  49. }  

 

 

2.web.xm配置监听器

Xml代码 
  1. <listener>  
  2.          <listener-class>com.jun.util.listener.InitListener</listener-class>   
  3. </listener>   

 

此时再运行你的struts2项目就行了

 

 


Tags: Google  struts  struts2  java  java基础  gae  

原创文章如转载,请注明:转载自:飞扬部落编程仓库 : http://www.busfly.net/csdn/

本文链接地址:http://www.busfly.net/csdn/post/804.html

如果你喜欢本文,请顶一下,支持我,你的支持是我继续发好文章的最大动力。谢谢。
好东西需要分享,快把本文发给你的朋友吧~!~

     
相关文章:




◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
Feed订阅集
网站分类
勤劳致富^.^
最近发表
最新评论及回复
最近留言
随机推荐文章
Powered By Z-Blog   STYLE by busfly . FatMouse
Copyright © 2007 巴士飞扬技术博客. . 沪ICP备07027972号. 会员群1(VS为主):3769186.