在spring配置文件里给stirng注入一个字符串,如下:
<bean id="fileTypeMemo" class="java.lang.String">
        <constructor-arg index="0" value="文件类型必须是TXT LOG"/>
    </bean>
然后jsp中添加一条记录,提交,struts2的配置文件是使用chain来跳转,如下:
<action name="addMarketType" class="etTypeAction" method="addMarketType">
            <result name="success" type="chain">queryMarketType</result>
            <result name="input">MarketTypeList.jsp</result>
        </action>
提交后,数据可以插入,可是会返回错误,如下:
There is no Action mapped for namespace [文件类型必须是TXT LOG] and action name [queryMarketType] associated with context path [/eimp].
红色的字是我刚刚注入的字符串,没有这个命名空间,如果去掉这中注入方式就可以正常了,各位大神有没有遇到过这样的问题?Spring

解决方案 »

  1.   

     <result name="input">MarketTypeList.jsp</result>改为
     <result name="input">/MarketTypeList.jsp</result>
      

  2.   

    <result name="success" type="chain">queryMarketType</result>queryMarketType这个action存在不?改为queryMarketType.action看看
      

  3.   

    感谢耐心回答,可是还是不行,这个action是存在的,因为如果去掉那种注入的方式就可以了。如果不用chain的方式的话,也可以正常跳转到jsp。
      

  4.   

    怎么看不到你name=queryMarketType的action呢?
      

  5.   

    <!-- 分类查询 -->
            <action name="queryMarketType" class="etTypeAction" method="queryMarketType">
                <result name="success">MarketTypeList.jsp</result>
                <result name="input">MarketTypeList.jsp</result>
            </action>
    呵,在这,代码没有贴全。
      

  6.   

    看看两个action里面的变量名是否相同,还要有get set方法。视图都要加上/
      

  7.   

    追问下:There is no Action mapped for namespace [文件类型必须是TXT LOG]为啥我注入的字符串会在这里,并提示没有action与之映射,去掉就没问题了,纠结了好久。。
      

  8.   

    这些都有了,因为还有一个整型的注入我也是同样的方式,如下:
    <bean id="fileSize" class="java.lang.Long">
            <constructor-arg index="0" value="5242880"/>
        </bean>
    这个就没有问题,会不会跟版本或包有啥关系的
      

  9.   

    你页面form看看,是否定义命名空间了。配置文件贴全。命名空间不要和参数名相同
      

  10.   


    这些问题都排除了,因为chain是可以用的,只是加入了这个注入就挂了,郁闷,能想到的基本上都试过了。。
      

  11.   

    问题解决了,要这样配置,如下:
    <action name="addMarketType" class="etTypeAction" method="addMarketType">
                <result name="success" type="chain">
                 <param name="namespace">/et/etType</param>
    <param name="actionName">queryMarketType</param>
    <param name="method">queryMarketType</param>
                </result>
                <result name="input">MarketTypeList.jsp</result>
            </action>
    注意红色的配置,有人知道这为什么吗?