对于JSP上的输入,我想显示与输入相关的建议。
我的控制器-
@GetMapping(value = "/customerAutoComplete")
@ResponseBody
public List<String> customerAutoComplete(@RequestParam(value = "term",
required = true, defaultValue = "") String term){
List<String> ls=new ArrayList<String>();
ls.add("L110");
ls.add("L111");
ls.add("L011");
return ls;
}
JSP页面-
<script type="text/javascript">
$(function() {
$("#customerCode").autocomplete({
source: "/customerAutoComplete",
minLength:2
});
});
</script>
//input somewhere in the file-
<div class="form-group">
<label for="customerCode" class="font-weight-bold ">Customer#</label>
<input type="text" class="form-control" name="customerCode" id="customerCode" required oninput="customerf()"/>
</div>
我当前在页面上-http://127.0.0.1:8080/Project-SNAPSHOT/贷款助学金表格
我已尝试将get映射值更改为"/loanDisbusralForm/customerAutoComplete";但仍然没有运气。
精确错误-
jquery-3.5.1.js:10099 GET http://127.0.0.1:8080/customerAutoComplete?term=L1 404 (Not Found)
注意-当我加载贷款支付表时,我也会收到这个错误,不知道它是否与此有关-
Refused to apply style from 'http://127.0.0.1:8080/Project-SNAPSHOT/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
使用正确版本的jquery,尤其是jquery ui解决了这个问题。