Blog / 阅读

SSH整合时出现的Unable to instantiate Action异常

by admin on 2014-04-05 12:59:30 in ,



   在ssh框架整合的时候,尽管你按照官方网站上的做法一步一步的整合了struts2,hibernate,spring,但是当你运行的时候,还是经常会出现一个异常,那就是Unable to instantiate Action。此异常表达的意思很明显,那就是不能初始化你的action。而出现以下异常,普遍都是因为以下原因:

一、在web.xml中没有配置spring的监听器或者没有配置spring配置文件的路径,从而造成spring中的bean不能被初始化。配置如下:

[html] view plaincopy
 <listener>  
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
</listener>  
<context-param>  
    <param-name>contextConfigLocation</param-name>  
    <param-value>  
        classpath*:/applicationContext.xml,  
        classpath*:/applicationContext-shiro.xml  
    </param-value>  
</context-param>  


二、如果你配置上面所说的,问题还没有解决的话,那原因有可能是你的service和dao的注入没有成功,这时候可以检查你的代码。如果你使用的是annotation的话,注意在spring配置文件中记得配置scan文件夹,这样你的bean才能被初始化。


[html] view plaincopy
<context:annotation-config />  
    <context:component-scan base-package="com.note" />  



写评论

相关文章

上一篇:C#自动添加using引用命名空间

下一篇:DES加密算法详解- -

评论

写评论

* 必填.

分享

栏目

赞助商


热门文章

Tag 云