`
lysvanilla
  • 浏览: 81163 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

No result defined for action and result input

阅读更多

    今天在学习struts2.2类型转换时,出现了No result defined for action and result input这个问题。在查看了许多这个问题的解释后总结如下:

    首先介绍下代码情况:

          1、com.test.action下有PointAction.java和PointAction-conversion.properties

          2、com.test.bean下有Point.java

          3、com.test.converter下有PointConverter.java

          4、WebRoot下有input.jsp和output.jsp

  

    出现这个问题的原因是:

          由于在PointConverter.java中设置的分隔符是英文的逗号“,”而在input.jsp页面输入时分隔符用的是中文的逗号“,”导致转换错误,而转换错误后就会返回到INPUT,而由于在struts.xml中没有设置返回值为input,也就是说没有<result name="input" >/output.jsp</result>,从而导致错误。注:这个input不是PointAction里返回的,估计应该是转换器里的。

 

    另外在类型转换时还可能出现的问题有:

          1、在PointAction-conversion.properties下point=com.test.converter.PointConverter中的point是要转换的具体的对象,而不是类。

          2、struts2.0,struts2.1和struts2.2各有不同,可能需要struts2-convention-plugin-2.1.8.jar

         

2
0
分享到:
评论
1 楼 lysvanilla 2010-12-24  
补充:
     对于action返回input的补充,查阅源代码后,我在com.opensymphony.xwork2包下的Action接口中看见如下代码:
         /**
     * The action execution require more input
     * in order to succeed.
     * This result is typically used if a form
     * handling action has been executed so as
     * to provide defaults for a form. The
     * form associated with the handler should be
     * shown to the end user.
     * <p/>
     * This result is also used if the given input
     * params are invalid, meaning the user
     * should try providing input again.
     */
    public static final String INPUT = "input";

由此可以得出action中input的来源。

相关推荐

Global site tag (gtag.js) - Google Analytics