我正在尝试使用 dojo 自动完成器对信息的哈希图进行 ajax 检索,但下拉菜单上似乎没有显示任何内容。请帮忙
我的 JSP 代码:
<sx:head/>
.......
<s:url id="companyList" action="AjaxAutoCompleteCompanyPOCAction" />
<sx:autocompleter name="company" href="%{companyList}" size="24" loadOnTextChange="true" preload="false" loadMinimumCount="1" showDownArrow="false" autoComplete="false" searchType="substring" key="rental.company"/>
我的 Struts.XML:
<action name="AjaxAutoCompleteCompanyPOCAction" class="com.kodi.action.jobs.AjaxAutoCompleteCompanyPOCAction" method="retrieveListOfCompany" >
<result type="json">
<param name="root">json</param>
</result>
</action>
我的行动
public String retrieveListOfCompany(){
//if(KodiUtil.isMatch(getCompany())){ // validate special char
setJson(new HashMap<String, String>()); // create a JSON hashmap
if(company != null && company.length() > 0) { // check if string is empty
List<CompanyEntity> companylist = manager.retrieveCompanyName(getCompany()); // retrieve the companies name
for (CompanyEntity companies : companylist){
getJson().put(companies.getCompany_name(),""+companies.getCompany_id());
}
}
return "SUCCESS";
}
截至目前,代码确实在我的 Action 类中调用了retrieveListOfCompany(),n 获取了数据但它没有显示在 JSP 页面上..请帮助..我收到这个错误,
No result defined for action com.kodi.action.jobs.AjaxAutoCompleteCompanyPOCAction and result SUCCESS
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
但是当我将我的 struts.xml 设置为
<result name="SUCCESS" type="json">
<param name="root">json</param>
</result>
我明白了=(
java.lang.NoSuchMethodError: com.opensymphony.xwork2.ActionContext.get(Ljava/lang/Object;)Ljava/lang/Object;
at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
我为此使用 struts2-dojo-plugin-2.1.8.1.jar
谢谢!