解决方案 »

  1.   

    spring管理bean里面,首字母不要用大写的id名字
      

  2.   

    你的spring已经管理了action.FirstAction类,所以在struts中引用action的class应该是是spring 中声明的相应的action的bean的id,这样才能将你struts.xml中引用的action的控制权交给spring,也就是struts.xml应该是:
    <action name="first" class="FirstAction" method="findAllFirstInfo">
    <result>index.jsp</result>
    </action>
      

  3.   

    既然你是让spring来管理Action,所以首先你必须得让struts将实例化Action的权限分配给spring,这个分配操作是通过配置Struts的配置文件来实现的,就是struts.properties里面加一行代码:
    struts.objectFactory=spring
    ,剩下的就像4楼说的那样了。
      

  4.   

    <action name="start" class="firstAction" method="findAllFirstInfo">
    <result>index.jsp</result>
    </action>
    @Controller
    @Scope("prototype")
    public class FirstAction extends ActionSupport {

    @Resource
    private NewsInterface ni;
    @Resource
    private MusicInterface mi;
    @Resource
    private SingerManageService si;
    public String findAllFirstInfo(){
    if(curPage<=0){
    curPage=1;
    }
    ne=ni.pageNews(curPage, PAGESIZE);
    ml=mi.pageMusic(curPage, PAGESIZE);
    singer=si.getAllSingers();
    totalCount=mi.findAllMusic().size();//总行数
    totalPage=totalCount%PAGESIZE==0?totalCount/PAGESIZE:totalCount/PAGESIZE+1;//总页数
    //判断上下页
    if(curPage<=1){
    pre=1;
    next=curPage+1;
    }else if(curPage>=totalPage){
    next=totalPage;
    pre=curPage-1;
    }else{
    pre=curPage-1;
    next=curPage+1;
    }
    //设定页数的数组
    numbers=new int[totalPage];
    for(int i=0;i<totalPage;i++){
    numbers[i]=i+1;
    }
    return SUCCESS;

    }action内的方法
    根据楼上更改后出现新问题[
    HTTP Status 404 - There is no Action mapped for namespace / and action name .--------------------------------------------------------------------------------type Status reportmessage There is no Action mapped for namespace / and action name .description The requested resource is not available.下面是现在的 struts配置文件 spring配置文件
    <action name="start" class="firstAction" method="findAllFirstInfo">
    <result>index.jsp</result>
    </action>spring
    <!-- 自动扫描和装配bean -->
    <context:component-scan base-package="*"></context:component-scan>web.xml
     <welcome-file-list>
        <welcome-file>start</welcome-file>
      </welcome-file-list>
      
      <!--spring自动读取配置文件applicationContext.xml-->
      <context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>classpath:applicationContext.xml</param-value>
      </context-param>
      <listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      
      
      <filter>
        <filter-name>encodeFilter</filter-name>
        <filter-class>util.EncodeFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>utf-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodeFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
        <filter>
       <filter-name>struts2</filter-name>
       <filter-class>
       org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
       </filter-class>
      </filter>
      <filter-mapping>
       <filter-name>struts2</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>感谢大家 dao类和impl接口实现类的注入没问题 大家一起看看是啥原因引起的下午结贴!