You should use a JSON library (see json.org) to generate valid JSON,
then write that directly to the response, returning null to indicate
to Spring that the response is already rendered.

Something like this:

searchVal =  ServletRequestUtils.getStringParameter(request, "q");
list= service.getResult(searchVal );
response.getWriter().write(new JSONArray(list).toString());
return null;

Jörn

On Thu, Dec 11, 2008 at 8:34 PM, anny <2000.ann.s...@gmail.com> wrote:
>
> I have jquery auto complete example working. Trying to integrate with
> spring MVC.
>
> I use InternalResourceViewResolver and SimpleUrlHandlerMapping.
>
> I am trying to pass url in autocomplete(url), which is mapped to
> multiactioncontroller which returns array based on value entered in
> tex box.
> But its returning entire jsp instead of array.
>
>
> Jsp
>
> Code:
> <html>
> <head>
>   <script src="http://code.jquery.com/jquery-latest.js";></script>
> <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/
> autocomplete/demo/main.css" type="text/css" />
>  <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/
> plugins/autocomplete/jquery.autocomplete.css" type="text/css" />
>  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/
> plugins/autocomplete/jquery.autocomplete.js"></script>
>  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/
> plugins/autocomplete/lib/jquery.bgiframe.min.js"></script>
>  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/
> plugins/autocomplete/lib/query.ajaxQueue.js"></script>
>  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/
> plugins/autocomplete/lib/thickbox-compressed.js"></script>
>  <script>
>  $(document).ready(function(){
>      var url = "searchResult.htm";
>    $("#example").autocomplete(url);
>      });
>  </script>
> </head>
> <body>
>  API Reference: <input id="example" /> (try "C" or "E")
> </body>
> </html>
>
>
> Here is what I return in multiaction actroller
>
> Code:
> searchVal =  ServletRequestUtils.getStringParameter(request, "q");
> list= service.getResult(searchVal );
> return new ModelAndView("SEARCH",  "Arr",  list.toArray());
>
> Thanks in advance.
> Any help will be appreciated.
>
> Anny
>
>

Reply via email to