没有为操作定义结果,也没有为验证输入结果

发布于 2024-12-10 07:00:25 字数 1285 浏览 0 评论 0原文

这是我

<struts>
  <include file="example.xml"/>

  <constant name="struts.devMode" value="true" />

  <package name="register" namespace="/register" extends="struts-default,json-default">
    <action name="Registration"  class="example.Registration">
      <result name="success">/SucessPage.jsp</result>
      <result name="input">/UserData.jsp</result>
    </action>

    <action name="validateEmailValue" method="validateEmailValue" 
            class="example.Registration">
      <result type="json"/>
    </action>
  </package>
</struts>

在 jsp 页面中的

<s:form action="http://localhost:8080/MyRegistrationProject/register/Registration" 
        name="data" validate="true"> 

struts.xml ,它验证数据,但在我的操作类中有 do 方法执行和 validateEmailValue

我已经使用 getjson 进行 ajax 调用

$.getJSON("http://localhost:8080/MyRegistrationProject/register/validateEmailValue",
    { email:emailId },
    function(data) { alert("success") }
);

当我调用 validateEmailValue 时,它​​会给出以下错误

No result defined for action example.Registration and result input

Any Insight ?谢谢

This is my struts.xml

<struts>
  <include file="example.xml"/>

  <constant name="struts.devMode" value="true" />

  <package name="register" namespace="/register" extends="struts-default,json-default">
    <action name="Registration"  class="example.Registration">
      <result name="success">/SucessPage.jsp</result>
      <result name="input">/UserData.jsp</result>
    </action>

    <action name="validateEmailValue" method="validateEmailValue" 
            class="example.Registration">
      <result type="json"/>
    </action>
  </package>
</struts>

in jsp page

<s:form action="http://localhost:8080/MyRegistrationProject/register/Registration" 
        name="data" validate="true"> 

it validate data but in my action class there are do method execute and validateEmailValue

I have make ajax call using getjson

$.getJSON("http://localhost:8080/MyRegistrationProject/register/validateEmailValue",
    { email:emailId },
    function(data) { alert("success") }
);

When I make call for validateEmailValue it gives following error

No result defined for action example.Registration and result input

Any Insight? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小姐丶请自重 2024-12-17 07:00:25

我相信您在操作类 example.Registration 中实现了 validate() 对吗?

即使您指定在操作 validateEmailValue 上调用方法 validateEmailValue(),它也会首先运行 validate() 并检查验证是否成功,如果验证失败,会将页面转发到 INPUT 结果。

由于您的 validateEmailValue 操作没有声明 INPUT 结果,系统会抛出您看到的错误。

尝试将 INPUT 结果添加到您的 validateEmailValue 操作中并查看显示的内容。

<result name="input" type="json"/>

I believe you implemented validate() in your action class example.Registration right?

Even though you specified to call the method validateEmailValue() on your action validateEmailValue, it will first run validate() and check if the validation succeed, and will forward the page to INPUT result if validation failed.

Since your validateEmailValue action do not have a INPUT result declared, system throw the error you saw.

Try adding the INPUT result to your validateEmailValue action and see what is shown.

<result name="input" type="json"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文