在用ajax獲得分頁數據時,無法將獲取的值賦值給input標簽,在修改用戶信息時不顯示用戶已經注冊的信息,百度可知
springmvc處理分頁數據返回的對象時,無法直接將對象轉換成json,會報org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type:錯誤,
需要在springmvc返回前先轉換為json
步驟如下:
1.添加依賴(pom.xml)
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.5</version>
</dependency>
2.指定Message對象轉換器(springmvc.xml)
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>
完成, 再次訪問可獲得ajax中的數據

