解決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);
相關文章
- java.lang.String cannot be cast to com.alibaba.fastjson.JSONObject解決辦法JavaASTJSONObject
- React報錯之Function components cannot have string refsReactFunction
- cannot be cast to java.lang.ComparableASTJava
- com.alibaba.fastjson.JSONObject cannot be cast to XXX異常解決ASTJSONObject
- Ubuntu Cannot allocate memory 錯誤解決方案Ubuntu
- SQL中欄位比較型別不匹配錯誤:‘cannot be cast to’SQL型別AST
- cenots7.6系統報“fork:Cannot allocate memory” 報錯的解決方法(實操)
- solrcloud頁面顯示報錯Cannot load analyzer問題的解決方法SolrCloud
- JAVA int 強制型別轉換錯誤提示(Cannot cast from Object to int)Java型別ASTObject
- mybatis報錯解決MyBatis
- Cause: java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.ibatis.mapping.MappedStatementJavaASTExceptionApacheBATAPP
- Linux系統yum安裝報錯Cannot find a valid baseurl for repo的解決方法Linux
- 解決fitz模組報錯
- SS報錯的解決
- 解決eslint報錯EsLint
- iText中文,報錯解決
- 報錯Intel MKL FATAL ERROR: Cannot load libmkl_core.so.的一種解決方法IntelErrorIBM
- virtualbox中Cannot register the hard disk錯誤解決辦法
- ORA-01407: cannot update to null 錯誤解決Null
- SyntaxError: EOL while scanning string literal錯誤解決ErrorWhile
- 關於React Native報Cannot access ‘serviceOf‘的解決方案React Native
- hive使用報錯解決方法Hive
- npm install 報錯解決NPM
- 解決 Cannot find OpenSSL's
- allowedOrigins cannot contain the gateway 報錯AIGateway
- 前端報錯:cannot read property length of undefined前端Undefined
- inplace-abn 報錯解決: ImportError: libcudart.so.9.0: cannot open shared object file: No such file or dirImportErrorDartObject
- android.app.Application cannot be cast to 新建的ApplicationAndroidAPPAST
- Workspace in use or cannot be created, choose a different one.--錯誤解決辦法
- ORA-01552: cannot use system rollback錯誤解決方法
- dbfread報錯ValueError錯誤解決方法Error
- PHP Fatal error: Cannot use PhpParser\Node\Scalar\String as StringPHPError
- mongodb find報錯怎麼解決MongoDB
- 解決 Inkscape 報錯 Duplicate 問題
- 解決angular 報錯 url unsafeAngular
- 安裝sass報錯解決方案
- sysctl -P 報錯解決辦法
- 幾個報錯的解決方法