我想用Struts1.2+Spring2.0+ibatis2.0整合一个框架出来。一开始做的时候,我是参照网上很多的例子,但是后来遇到了这么一个问题:Struts的Action使用的是DispatchAction。当我把Struts的Action交给Spring进行管理的时候(在applicationContext.xml中写入)比如:<bean id="loginAction" 
class="com.inspur.china.action.LoginAction" >
<property name="loginService">
<ref bean="loginService" />
</property>
</bean>那么前台页面的语句为:    window.open("<%=path %>/login.do?method=getLogin"); 
    
或者是:<form action="<%=path %>/login.do?method=getLogin" method="post">
    </form>的时候页面是无法执行Action中相对应的方法的。这个问题如何解决?请各位回答详细一些,谢谢!

解决方案 »

  1.   

    你提供的信息不够多啊...发个struts的xml文件看下..这么少东西哪知道什么地方出问题了.!
      

  2.   

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <package name="login" extends="struts-default">
    <action name="loginAction" method="login">
    <interceptor-ref name="params"/>
    <result></result>
    </action>
    </package>
    </struts>
    以上就是struts.xml文件的内容
      

  3.   

    上面那个发错了,这个才是 :struts-config.xml文件的内容
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
      <data-sources />
      <form-beans >
        <form-bean name="loginForm" type="com.inspur.china.form.LoginForm" />  </form-beans>  <global-exceptions />
      <global-forwards />
      <action-mappings >
        <action
          attribute="loginForm"
          input="/login/index.jsp"
          name="loginForm"
          parameter="method"
          path="/login"
          scope="request"
          type="org.springframework.web.struts.DelegatingActionProxy">
          <forward name="success" path="/login/index.jsp" />
          <forward name="fail" path="/" />
        </action>  </action-mappings>  <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"/>
      <message-resources parameter="com.inspur.china.struts.ApplicationResources" />
      <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
      </plug-in>
    </struts-config>
      

  4.   


    applicationContext.xml 中的<bean name="/login" >
    与struts-config.xml 中的 path="/login" 是一致的
    只有这样它才会执行LoginAction类里边的方法applicationContext.xml 中的<ref bean="loginService"/>
    loginService这个一般式类名 你的是不是类名呢?
    类名规范一点 首字母都要大写的