在Struts 2的使用后自动完成的行动没有结果的定义 [英] No result defined for action after using autocomplete in Struts 2

查看:176
本文介绍了在Struts 2的使用后自动完成的行动没有结果的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为结果输入操作定义没有结果的误差。它不来,直到我用Struts2的自动完成的时间。

I am getting an error of No result defined for action for result input. It was not coming till the time I used Struts2 autocomplete.

这是我的自动完成code:

This is my autocomplete code :

<s:form class="form-horizontal" style="margin:0 auto" role="form" theme="simple" action="Reports_open_cases">
 <h4>Open Cases</h4>

  ..some controls here

<div class="form-group">              
<div class="col-xs-12 col-sm-4 col-md-4"></div>
 <div class="col-xs-12 col-sm-4 col-md-4" >
 <s:url id="advURL" action="xyz_action"/>    
<sj:select 
 id="abc"  
 name="abc" selectBoxIcon="true"
 href="%{advURL}" 
 list="list_abc" 
 listValue="name" 
 listKey="Id "  
 autocomplete="true"  
 cssClass="form-control"
/>  
</div>

<div class="col-xs-12 col-sm-12 col-md-12 pull-right" style="text-align:right"><br>
     <div class="modal-footer" style="margin:0px; padding:10px 0px 10px">
             <button class="btn btn-success"  type="submit">Generate</button>
            &nbsp;&nbsp;        
            <button class="btn btn-default"  type="Reset">Reset</button>
      </div>
</div>
</s:form>     

我的的struts.xml (动作):

<constant name="struts.devMode" value="true" />
<constant name="struts.multipart.maxSize" value="20000000" />      
<package name="login" extends="struts-default,json-default" namespace="/">
    <interceptors>
        <interceptor class="vercelon.actions.LoginInterceptor" name="loginInterceptor">
        </interceptor>    
        <interceptor-stack name="loginStack">
        <interceptor-ref name="loginInterceptor"/>
        <interceptor-ref name="defaultStack"/>
        <interceptor-ref name="fileUpload"><param name="maximumSize">10485760</param>
  </interceptor-ref>
    </interceptor-stack>  

    </interceptors>    

<action name="Reports_open_cases" class="vercelon.actions.Report" 
                                 method="Generate_OpenCases">
    <result name="success">/CMS/Reports_OpenCases.jsp</result>
    <result name="ERROR">/Error.jsp</result> 
    <result name="input">/CMS/Reports_Menu.jsp</result>
</action> 

<action name="xyz_action" class="vercelon.actions.Report" method="loadreports">
        <result name="success" type="json"></result>
    </action>

其他然后替换下拉列表自动完成,我还没有做出任何其他更改。当我添加输入到我的的struts.xml 它不显示此错误。但定义为我的形式提交的行动也不起作用。
我不明白的地方,我需要添加此自动完成后进行更改。请帮助。

Other then replacing the dropdown to the autocomplete, I haven't made any other changes. When I add input to my struts.xml it doesn't show this error. But the action defined to my form submit doesn't work either. I don't understand where I need to make changes after adding this autocomplete. Please help.

推荐答案

当你调用从拦截器执行该操作之前运行视图层的一些动作。看来你的动作中使用默认的堆栈,其中包括验证工作流程拦截器。第一个拦截器上执行,如果有,则返回输入的结果误差延长 ActionSupport的,第二次检查行动验证。但是如果你使用的动作类的一些 -validation.xml 或基于注解的验证,所以每一个映射这个类的方法操作由拦截器上面验证,除非你配置这些拦截器排除的方法,或使用prefixed基于验证方法,或跳过验证注释应用。所有这些情况,以避免那些没有使用过一些行动,需要避免它们或重新配置拦截器栈没有这些拦截器运行code运行验证。你的情况,返回动作 JSON 结果不需要字段,而不是一个的验证。如何配置和覆盖行动拦截器的配置看问题:?如何获得导致同一页上为什么需要输入

When you call some action from the view layer the interceptors run before the action is executed. Seems your actions use default stack which include validation and workflow interceptors. First interceptor performs validations on actions that extend ActionSupport, the second check if there were errors the INPUT result is returned. But if you use some -validation.xml or annotation based validations on action class, so every action that is mapped the method of this class is validated by the interceptors above, unless you have configured these interceptors to exclude a method, or use prefixed based method of validation, or skip validation annotation is applied. All these cases to avoid running validators for the code that haven't been used by some action and needs to avoid them or reconfigure interceptor stack to run without these interceptors. In your case the action that returns json result doesn't need validation of fields rather than a term. How to configure and override interceptors configuration of the action see in question: How to get result on same page why input is required?.

使用选择箱体采用JSON结果作为Autocompleter 。结果
<一href=\"https://$c$c.google.com/p/struts2-jquery/source/browse/trunk/struts2-jquery-showcase/src/main/java/com/jgeppert/struts2/jquery/showcase/Autocompleter.java\"相对=nofollow>在这个例子
使用的操作源$ C ​​$ C。

The working example that uses Select Box with JSON Result as Autocompleter.
The actions source code used in the example.

这篇关于在Struts 2的使用后自动完成的行动没有结果的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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