如何获得导致同一个页面上输入为什么需要?如何获得、页面

由网友(无人像你)分享简介:在我的项目,我更新的细节,所以我创建行动,但它给了我异常响应,In my project I am updating details so I created action, but it gives me exception in response asNo result defined for action o...

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

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.

阅读全文

相关推荐

最新文章