Ensure you have a getter:
public List<String> getFruitslist() {
return fruitslist;
}
Since you posted your struts.xml and now it's clear that you want to use JSON, the code must be changed. The previous answer was referring to a standard Array from the main Action; in case of a JSON action, you need to specify an url in href
attribute of the autocompleter to point to the separate JSON Action:
<s:url var="remoteurl" action="ajaxAction"/>
<sj:autocompleter
id="fruitslist"
href="%{remoteurl}"
delay="50"
loadMinimumCount="2"
/>
Then you need to set your result as JSON, and your root
object to your Array, like this:
<action name="ajaxAction" class="org.struts.action.AjaxJsonAction">
<result name="success" type="json">
<param name="root">
fruitslist
</param>
</result>
</action>
I strongly suggest you to read how the Struts2-JSON plugin works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…