SSM遇到的問題(四)

1. ajax請求錯誤:$.get is not a function

JQuery: $.get is not a function

解決:css

<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
複製代碼

改爲java

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
複製代碼

額外擴展:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
複製代碼

如今的boostrap的引用中多了integritycrossorigin兩個屬性,瞭解一下,做用是什麼?jquery

What are the integrity and crossorigin attributes?ajax

大概就是,引入兩個屬性,保證資源的完整性。也能夠不引用。spring

2.SSM的頁面有ajax請求返回數據,返回失敗。

提示:返回的類型對象沒法轉換成json輸出。


  1. Failed to write HTTPmessage:org.springframework.http.converter.HttpMessageNotWritableException: Nojson

  2. java.lang.IllegalArgumentException: No converter found for return value of typebootstrap

    由此瞭解到要想輸出轉換成爲json對象,要保證類型的字段屬性,都有開放(public)的getter/setterbash


  1. Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Comvc

    由此瞭解到,若是轉換的類型中有些字段不須要生成時,能夠使用 @JsonIgnoreProperties() 來忽略生成json對象的屬性。app


  1. SpringMVC返回對象類型報錯HttpMessageNotWritableException: No converter found for return value of type

    json配置

    <!--fastjson的配置-->
        <mvc:annotation-driven>
            <mvc:message-converters>
                <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
                    <property name="supportedMediaTypes" value="application/json;charset=utf-8"/>
                </bean>
            </mvc:message-converters>
        </mvc:annotation-driven>
    複製代碼

    解決:很尷尬,由於沒有進行配置,因此出現,沒法轉換json對象的錯誤。

相關文章
相關標籤/搜索