why autocomplete does not work with JSON and SPRING MVC

I am puzzled why autocomplete does not work. Here is the form in the .jsp code below:

<form:form method="post" action="save.html" modelAttribute="word">
            <th>German word</th>
            <td><form:input path="german" id="german" /></td>
            <td colspan="2"><input type="submit" value="Save" /></td>
    <br />

here are the javascript functions (in the same .jsp file)

$(document).ready(function() { 
$( "#german" ).autocomplete({
    source: '${pageContext. request. contextPath}/get_word_list.html'


and here is the relevant part of the controller:

private WordService wordService;

@RequestMapping(value = "/goToDictionary", method = RequestMethod.GET)
public ModelAndView index() {

    Word word = new Word();
    return new ModelAndView("dictionary", "word", word);

@RequestMapping(value = "/get_word_list", method = RequestMethod.GET, headers = "Accept=*/*")
public @ResponseBody
List<String> getCountryList(@RequestParam("term") String query) {
    return getMatch(query);

public List<String> getMatch(String query) {
    query = query.toLowerCase();
    List<String> matched = new ArrayList<String>();
    for (Word v : wordService.getAllWord()) {
        if (v.getGerman().toLowerCase().startsWith(query)) {
    return matched;

I know for sure that the getMatch(String query) gets called and works properly. So I guess the problem is on the jsp. file

any help is greatly appreciated.


[For JSON to fill the list] Maybe you should look at the produces property of the @RequestMapping annotation. It takes a String[] as value. Available since Spring 3.1.x version. I currently use the 3.1.2 and I can get some application/json without any problem.

And of course you should add the produces in the data provider of your country list.

[For JavaScript to fill the list] Maybe the part ${pageContext. request. contextPath} is not evaluated correctly. Did you check inside the produced code of your JSP e.g. with Firebug.

OK, I have found the solution. it is in the spring-servlet.xml file. It did not work because i failed to add this.

xsi:schemaLocation="ttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

I added, and now everything is OK

Need Your Help

Entity Framework Foreign Key Queries

entity-framework foreign-keys entity

I have two tables in my entity framework, objects, and parameters which have a foreign key pointing to the object to which they belong. I want to populate a tree with all the attributes of a certain

Kill/Yank (cut/paste) in ZSH

linux command-line emacs zsh

I use zsh and have the Emacs keybindings set up for it. I'd love to have it replicate all my regular Emacs text manipulation commands. One which I miss is the Kill/Yank keys. It would be nice if I ...