Servlet action is not available 问题解决

 

      环境eclipse3.2+myeclipse+tomcat5.0x

       重要提示:出现这个问题的原因很多,最多见的是配置文件出错不能初始化出现Servlet action is not available提示。要解决问题需要具体问题具体分析,多看容器的logs。

       背景提示,我要做struts+spring+hibernate的配置,但是按照书上说的配置好了后,总是错误,提示Servlet action is not available后台log就提示2006-03-22 22:34:09 StandardWrapperValve[action]: Servlet action is currently unavailable。弄了很久没有弄好。后来看了很久的log才发现提示配置文件中有错误,所以把action设置为null。

在找这个错误,找了很久才发现:一个是


    
< plug-in
        
className ="org.springframework.web.struts.ContextLoaderPlugIn" >
        
< set-property  property ="contextConfigLocation"
            value
="/WEB-INF/classes/applicationContext.xml"   />
    
</ plug-in >

在struts中配置spring插件时,applicationContext.xml(spring的配置文件)位置错了,书上一般是"/WEB-INF/applicationContext.xml"  但是有的时候不是在这个下面。所以一定要自己到容器下看看具体位置。比如我的就是在web-inf/classes下。

   二是:在spring的配置文件下的插入hibernate的配置文件

     < bean  id ="SessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
        
< property  name ="configLocation" >
            
< value > file:src/hibernate.cfg.xml </ value >
        
</ property >
    
</ bean >

myeclipse自动添加的是这样的,我一直没有注意,结果应该为:

     < bean  id ="SessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
        
< property  name ="configLocation" >
            
< value > file:src/hibernate.cfg.xml </ value >
        
</ property >
    
</ bean >

提示:hibernate.cfg.xml文件的具体位置你要到容器下去看。

重要提示:

1、还有就是一定要在struts配置文件中加: <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"/>。这样你的action才能真的委托给spring。

2、我发现我的myeclipse没有把spring.jar拷贝到lib下,以后大家出了问题可以看看。

     利用spring+hibernate+struts过程中,发现一个问题,在action中将一个hibernate读取出来的ArrayList存入session:request.getSession().setAttribute("treeFromRoot", treeList.iterator());

在jsp中用标签 读取代码如下:会出现Cannot create iterator for this collection 错误,弄了一下午都没有搞定。

< logic:notEmpty  name ="treeFromRoot" >
   
< logic:iterate  type ="edu.scnu.es.struts.vo.Tree"  id ="tree"
    name
="treeFromRoot" >


   
</ logic:iterate >
  
</ logic:notEmpty >  

最后决定用JSTL试一试,代码改为:成功了。

< c:forEach   items ="${sessionScope.treeFromRoot}"   var ="treeFromRoot1" >
    ${treeFromRoot1.id };
</ c:forEach >

其中:edu.scnu.es.struts.vo.Tree是treeFromRoot这个list的成员的原形类。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值