qq_36346496
violent_sunset
采纳率0%
2017-05-16 10:10

myeclipse 中struts和spring整合问题

求大神帮忙

我在配置struts.xml文件的action如下:


 <action name="*" class="edu.fjnu.zkl.action.MemberAction" method="{1}">
            <result name="input">/jsps/reg_member.jsp</result>
            <result name="toInputAction" type="redirectAction">toInput</result>
            <result name="listAction" type="redirectAction">listAction </result>
            <result name="list">/jsps/reg_member.jsp</result>
            <result name="update">/jsps/update_member.jsp</result>
        </action>

可以正常运行。
但是我在加入spring的bean之后进行修改:

 <constant name="struts.objectFactory" value="spring" /> 
 <constant name="struts.objectFactory.spring.autoWire" value="name"></constant>
........

<action name="*" class="memberAction" method="{1}">
            <result name="input">/jsps/reg_member.jsp</result>
            <result name="toInputAction" type="redirectAction">toInput</result>
            <result name="listAction" type="redirectAction">listAction </result>
            <result name="list">/jsps/reg_member.jsp</result>
            <result name="update">/jsps/update_member.jsp</result>
        </action>

这样运行程序正常编译运行,但是我访问资源的时候出现action无法匹配到。
然后我检查console中:

 defining beans [memberDao,memberService,memberAction,testAction,dataSource,sessionFactory,hibernateTemplate]; root of factory hierarchy

这些bean好像都正常的,所以想问问这个问题何解?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • qq_37502106 ChaseDreamBoy 4年前

    应该是spring 的bean配置有问题

    点赞 评论 复制链接分享
  • qq_36346496 violent_sunset 4年前
     <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
             http://www.springframework.org/schema/context
             http://www.springframework.org/schema/context/spring-context-3.0.xsd
             http://www.springframework.org/schema/tx
             http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
             http://www.springframework.org/schema/aop 
             http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
             default-autowire="byName" default-lazy-init="true">
    
        <bean id="memberDao" class="edu.fjnu.zkl.dao.implement.MemberDaoImpl">
            <property name="sessionFactory" ref="sessionFactory"></property> 
        </bean>
    
        <bean id="memberService" class="edu.fjnu.zkl.service.implement.MemberServiceImpl">
            <property name="memberDao">
                <ref local="memberDao" />
            </property>
        </bean>
        <!-- <bean id="memberService" parent="HibernateProxyTemplate"> <property 
            name="target"> <ref bean="memberServiceTarget"/> </property> </bean> -->
    
        <bean id="memberAction" class="edu.fjnu.zkl.action.MemberAction"
            scope="prototype">
            <property name="memberService">
                <ref bean="memberService" />
            </property>
        </bean>
    
        <bean id="testAction" class="edu.fjnu.zkl.action.TestAction"></bean>
    </beans>
    
    点赞 评论 复制链接分享
  • qq_36346496 violent_sunset 4年前

    <?xml version="1.0" encoding="UTF-8"?>
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
    default-autowire="byName" default-lazy-init="true">

    <bean id="memberDao" class="edu.fjnu.zkl.dao.implement.MemberDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"></property> 
    </bean>
    
    <bean id="memberService" class="edu.fjnu.zkl.service.implement.MemberServiceImpl">
        <property name="memberDao">
            <ref local="memberDao" />
        </property>
    </bean>
    
    
    <bean id="memberAction" class="edu.fjnu.zkl.action.MemberAction"
        scope="prototype">
        <property name="memberService">
            <ref bean="memberService" />
        </property>
    </bean>
    
    <bean id="testAction" class="edu.fjnu.zkl.action.TestAction"></bean>
    

    点赞 评论 复制链接分享
  • qq_27020369 天才小彩笔i 4年前

    Spring的application贴出来阿

    点赞 评论 复制链接分享

为你推荐