我正在尝试使用spring mvc的jquery自动完成功能 我正在使用弹簧3.2.3罐子 杰克逊映射器-ASL-1.9.7 杰克逊的数据类型,JSON-ORG-2.0.2 杰克逊核心ASL-1.9.7 jackson-core-2.0.2用于我的应用程序。
<script type="text/javascript">
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$(document)
.ready(
function() {
$("#userName")
.autocomplete(
{
minLength : 2,
source : '${pageContext. request. contextPath}/get_country_list.htm'
});
$("#technologies")
.autocomplete(
{
source : function(request,
response) {
$
.getJSON(
"${pageContext. request. contextPath}/get_tech_list.htm",
{
term : extractLast(request.term)
}, response);
},
search : function() {
// custom minLength
var term = extractLast(this.value);
if (term.length < 1) {
return false;
}
},
focus : function() {
// prevent value inserted on focus
return false;
},
select : function(event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms
.join(", ");
return false;
}
});
});
</script>
我的控制器就像这样
@RequestMapping(value = "/get_country_list", method = RequestMethod.GET, headers = "Accept=*/*")
public @ResponseBody
List<String> getCountryList(@RequestParam("term") String query) {
List<String> countryList = dummyDB.getCountryList(query);
System.out.println("aotuController"+query);
if(!countryList.isEmpty())
{
System.out.println(countryList.get(0));
}
return countryList;
}
@RequestMapping(value = "/get_tech_list", method = RequestMethod.GET, headers = "Accept=*/*")
public @ResponseBody
List<String> getTechList(@RequestParam("term") String query) {
List<String> countryList = dummyDB.getTechList(query);
return countryList;
}
在运行时显示错误 406不可接受 。