【问题标题】:GET 404 not found jquery AutocompleteGET 404 未找到 jquery 自动完成
【发布时间】:2021-04-04 02:08:25
【问题描述】:

对于 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/loanDisbursalForm

我尝试将获取映射值更改为 -"/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.

【问题讨论】:

    标签: javascript java jquery jsp controller


    【解决方案1】:

    使用正确版本的 jquery,尤其是 jquery ui 解决了这个问题。

    【讨论】:

    • 我也有类似的情况,但是jquery函数没有调用控制器函数,在控制器中你有一个变量'term',它是如何从jsp传递的?
    • 什么版本的jquery-ui 和jquery 解决了你的问题?请发布您的答案的确切版本
    • maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    • 谢谢,但所有这些链接现在都坏了!正如您提到的那样,其中没有 Jquery-ui 可以解决问题,它不需要吗?
    猜你喜欢
    • 2018-12-18
    • 1970-01-01
    • 2015-01-28
    • 2015-07-26
    • 1970-01-01
    • 2014-02-14
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    相关资源
    最近更新 更多