第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

訪問url的時候報500轉換錯誤

我查詢出了數(shù)據(jù),但是Controll返回值為什么不能是List,其他的String,Date,Int都可以,下面是錯誤的提示:

No converter found for return value of type: class java.util.ArrayList

正在回答

6 回答

List轉json的時候要配置轉換器;增加的配置類繼承WebMvcConfigurerAdapter 再重寫configureMessageConverters方法 下面是我寫得;你試試看!

????????
@Override
public?void?configureMessageConverters(List<HttpMessageConverter<?>>?converters)?{
???super.configureMessageConverters(converters);

???FastJsonHttpMessageConverter?fastConverter?=?new?FastJsonHttpMessageConverter();

???FastJsonConfig?fastJsonConfig?=?new?FastJsonConfig();
???fastJsonConfig.setSerializerFeatures(
???????????SerializerFeature.WriteNullListAsEmpty,
???????????SerializerFeature.WriteMapNullValue,
???????????SerializerFeature.WriteNullStringAsEmpty
???);
???fastConverter.setFastJsonConfig(fastJsonConfig);

???List<MediaType>?supportedMediaTypes?=?new?ArrayList<MediaType>();
???supportedMediaTypes.add(MediaType.ALL);
???fastConverter.setSupportedMediaTypes(supportedMediaTypes);
???converters.add(fastConverter);
}


1 回復 有任何疑惑可以回復我~
#1

小小騷年郎 提問者

非常感謝!
2017-11-18 回復 有任何疑惑可以回復我~

不知道具體搜什么,能否提供一個wiki,對相關內容進行一個簡要說明&lt;textareaclass=form-controlrows=3resize=none&gt;&lt;/textarea&gt;

0 回復 有任何疑惑可以回復我~

代碼奉上

Controll:

http://img1.sycdn.imooc.com//59ff03e40001be9a09200376.jpg

Repository:

http://img1.sycdn.imooc.com//59ff03e50001fa6b06140204.jpg

User實體類:

http://img1.sycdn.imooc.com//59ff03e60001297b07310604.jpg

application.yml:

http://img1.sycdn.imooc.com//59ff03e60001ab4d04920291.jpg

Service:

http://img1.sycdn.imooc.com//59ff03e700013b3204600373.jpg

求大佬解答?。。?!

0 回復 有任何疑惑可以回復我~

這個是錯誤的提示:

2017-11-05?20:19:45.190?ERROR?8632?---?[nio-8000-exec-3]?o.a.c.c.C.[.[.[/].[dispatcherServlet]????:?Servlet.service()?for?servlet?[dispatcherServlet]?in?context?with?path?[]?threw?exception?[Request?processing?failed;?nested?exception?is?java.lang.IllegalArgumentException:?No?converter?found?for?return?value?of?type:?class?java.util.ArrayList]?with?root?cause
java.lang.IllegalArgumentException:?No?converter?found?for?return?value?of?type:?class?java.util.ArrayList

其他地方和作者基本都一樣的

0 回復 有任何疑惑可以回復我~

Controll類:

package?com.example.helloboot.Controll;
import?com.example.helloboot.dao.UserRepository;
import?com.example.helloboot.entity.User;
import?com.example.helloboot.service.UserService;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.web.bind.annotation.RequestMapping;
import?org.springframework.web.bind.annotation.RestController;
import?java.util.List;

Repository接口:

package?com.example.helloboot.dao;
import?com.example.helloboot.entity.User;
import?org.springframework.data.jpa.repository.JpaRepository;
import?java.util.List;

Service類:

package?com.example.helloboot.service;
import?com.example.helloboot.dao.UserRepository;
import?com.example.helloboot.entity.User;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.stereotype.Service;
import?java.util.List;

導入的包沒問題的

0 回復 有任何疑惑可以回復我~

包引入錯了包,你在導入ArrayList包時,導入的不是 java.util?下的包吧


0 回復 有任何疑惑可以回復我~
#1

小小騷年郎 提問者

包沒問題
2017-11-05 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
2小時學會Spring Boot
  • 參與學習       151544    人
  • 解答問題       1132    個

Spring Boot入門視頻教程,你將學會使用Spring Boot快速構建應用程序

進入課程

訪問url的時候報500轉換錯誤

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號