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对象的错误。