如何获得导致同一个页面上输入为什么需要? [英] How to get result on same page why input is required?

查看:105
本文介绍了如何获得导致同一个页面上输入为什么需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我更新的细节,所以我创建行动,但它给了我异常响应,

In my project I am updating details so I created action, but it gives me exception in response as

No result defined for action org.employee.actions.EmployeeMyProfileAction and result input

的struts.xml (前)

<action name="savePersonalDetails"  class="org.employee.actions.EmployeeMyProfileAction" method="updateEmployeeDetails">
        <result name="success">empMyProfile.jsp</result>
</action>

(后)

<action name="savePersonalDetails" class="org.employee.actions.EmployeeMyProfileAction" method="updateEmployeeDetails">
    <result name="success">empMyProfile.jsp</result>
    <result name="input">emp-personal-form.jsp</result>
</action>

Ajax调用

Ajax Call

function checkPersonal(id) {

    if (checkEverythingP()) {
        $.ajax({
            type : 'POST',
            url : 'savePersonalDetails',
            data : $('#personalform').serialize(),
            success : function(data) {
                alert('success');
            },
            error : function() {
                alert('error');
            }
        });
    }
}

这让我在JQuery中成功的消息,但它不会宣布action类。我不明白为什么它正在发生后,一切正常。我提到许多网站对于这一点,但没有得到解决。请建议我什么错误。

It gives me success message in JQuery but It is not going to the action class declared. I didn't understand why it is happening after everything is correct. I referred many sites for this but not resolved. Please suggest me what is going wrong.

推荐答案

像你想象的,并非一切都是正确的,因为在成功回调函数您收到输入的结果。这个结果是由 工作流程返回拦截,这是在 defaultStack - 默认情况下使用,如果你的动作不会覆盖拦截器配置拦截器堆栈。它检查动作调用了验证错误样动作错误或CRC错误(转换错误)然后返回由参数中指定的结果 inputResultName 。默认情况下此参数设置为输入。如果拦截器返回一个结果它打破了拦截器链和行动方法调用。你注意到它说的这是不会宣布动作类的。

Not everything is correct as you thought, because in the success callback function you have received INPUT result. This result is returned by workflow interceptor, which is in the defaultStack - the stack of interceptors used by default if your action doesn't override the interceptors configuration. It checks if an action invocation has validation errors like action errors or field errors (the conversion errors) then returns a result specified by the parameter inputResultName. By default this parameter is set to "input". If the interceptor returns a result it breaks a chain of interceptors and invocation of action method. You noted it saying It is not going to the action class declared.

解决方案是覆盖行动拦截器配置为使用基本协议栈,即没有验证和/或工作流程拦截。

The solution is to override interceptors configuration of the action to use basic stack, i.e. without validation and/or workflow interceptors.

<action name="savePersonalDetails"  class="org.employee.actions.EmployeeMyProfileAction" method="updateEmployeeDetails">
  <interceptor-ref name="basicStack"/>
  <result name="success">empMyProfile.jsp</result>
</action>

如果您仍然需要进行验证,你可以做到这一点的编程的或配置工作流程拦截器来过滤你的操作方法。如果你有足够的理由,你应该只使用最后一个选择这样做,是因为它克服了拦截器本身的目的。

If you still need to perform validations you can do it programmatically or configure workflow interceptor to filter your action method. The last option you should use only if you have enough reasons to do so, because it overcomes the purpose of the interceptor itself.

这篇关于如何获得导致同一个页面上输入为什么需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆