开发者

Question on Struts 2 and Struts-jQuery Autocompleter

U开发者_JS百科pdate: I get the result using firebug, but the result doesn't show on the pages? Anyone knows why?

the result are like :

{"results":["hello","bye"]}

(PS: the jason plugin I posted is deprecated, which fires an error. I switched to the default struts-jason-plugin now).

Hi everyone, i got a problem on making the working. I'm using the latest version of all the dependencies. (Struts 2.2.1) I wanna do a live search from database using . here's the code in my JSP file:

<sj:autocompleter name="movieName" id="movieName"
                                href="%{jsonlanguages}" 
                                delay="50" 
                                loadMinimumCount="2"
                                ></sj:autocompleter>

jsonlanguages refers to a action, which i defined it like

 <s:url id="jsonlanguages" action="movieLiveSearch"/> 

now the current state is that this action is called when user type in the autocompleter, but no dropdown list containing results are returned.

My Action's execute function is defined like this:

public String display() throws IOException {
    System.out.println("execute movie live search");
    results.add("hello");
    results.add("goodbye");     
    return "SUCCESS";
}

where results is defined as

private List<String> results;

currently i just wanna return the variable results.(leave db apart for now). And my struts.xml file:

<result-types>
    <result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/>
</result-types>

<action name="movieLiveSearch" class="proj.MovieManagement.controller.MovieLiveSearchAction" method="display">
<result type="json" name="SUCCESS">admin.jsp</result>
</action>

Personally, i think the action didn't return the result, but I have no idea how to do that, can anyone tell me how to fix things?


Modify the result of action in struts.xml as follows:

<result type="json" name="SUCCESS"><param name="root">results</param></result>

The root parameter that we specify is the name of the variable from Action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜