解決String cannot be cast to java.util.List報錯
string型別轉list實體類集合
controller層用@RequestParam Map<String, Object> params接收前端傳值,例如
@RequestMapping("/test")
public List<Entity> tset(@RequestParam Map<String, Object> params){
List<Entity> list= (List<Entity>) params.get("Entity");
return list;
}
轉換時會報錯:String cannot be cast to java.util.List
解決方法:
使用阿里的fastjson
List list = JSON.parseArray(“你的json字串”, Model.class); (Model是你的實體)
List<Entity> list= JSON.parseArray(params.get("Entity").toString(), Entity.class);
相關文章
- com.alibaba.fastjson.JSONObject cannot be cast to XXX異常解決ASTJSONObject
- React報錯之Function components cannot have string refsReactFunction
- Cause: java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.ibatis.mapping.MappedStatementJavaASTExceptionApacheBATAPP
- SQL中欄位比較型別不匹配錯誤:‘cannot be cast to’SQL型別AST
- Ubuntu Cannot allocate memory 錯誤解決方案Ubuntu
- cenots7.6系統報“fork:Cannot allocate memory” 報錯的解決方法(實操)
- object dict cannot be used in await expression報錯解釋ObjectAIExpress
- Java更新資料庫報錯:Data truncation: Cannot create a JSON value from a string with CHARACTER SETJava資料庫JSON
- allowedOrigins cannot contain the gateway 報錯AIGateway
- SyntaxError: EOL while scanning string literal錯誤解決ErrorWhile
- 報錯Intel MKL FATAL ERROR: Cannot load libmkl_core.so.的一種解決方法IntelErrorIBM
- mybatis報錯解決MyBatis
- 解決eslint報錯EsLint
- gateway 報錯 allowedOrigins cannot contain the specialGatewayAI
- 解決Cannot resolve com.alibaba.cloud:aliyun-oss-spring-boot-starter:unknown 檔案上傳報錯aliCloudEdasSdk解決CloudSpringboot
- 完美解決SqlServer2012啟動報錯(cannot find one or more components.Please reinstall the application。)SQLServerAPP
- inplace-abn 報錯解決: ImportError: libcudart.so.9.0: cannot open shared object file: No such file or dirImportErrorDartObject
- 關閉tomcat報錯Cannot allocate memoryTomcat
- 前端報錯:cannot read property length of undefined前端Undefined
- SS報錯的解決
- iText中文,報錯解決
- supervisor使用報錯解決
- npm install 報錯解決NPM
- 報錯內容解決
- 關於React Native報Cannot access ‘serviceOf‘的解決方案React Native
- dbfread報錯ValueError錯誤解決方法Error
- java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to com.JavaASTExceptionJSONObject
- pip 安裝selenium報錯:Cannot fetch index base URL https://pypi.python.org/simple/怎麼解決??IndexHTTPPython
- 使用pillow開啟TIFF檔案報tempfile.tif: Cannot read TIFF header錯誤的解決方案Header
- VSCode中Flow報錯解決VSCode
- Windows分割槽報錯解決Windows
- minio報錯SignatureDoesNotMatch解決方案
- hive使用報錯解決方法Hive
- 解決啟動openfeign報錯
- 解決angular 報錯 url unsafeAngular
- 解決fitz模組報錯
- SyntaxError: Non-ASCII character 與 Cannot decode using encoding "ascii" 錯誤解決ErrorASCIIEncoding
- 解決cannot find module providing package或cannot find main modulePackageAI