When the controller in spin receives entity parameters
if there is a list attribute in the entity, an error will be reported when the list value is too large
public class Model{ private List<String> strings; }
Error Messages: “Invalid property ‘rynrlist[256]’ of bean class [com.ac.intellsecurity.model.exam.records.ExamTrainingRecordsModel]: Index of out of bounds in property path ‘rynrlist[256]’; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256”
Reason:
Solution:
1. modified into jsonobject to receive parameters and then converted into an entity (recommended)
@RestController @RequestMapping("/controller") public class Controller { //Before Modified @PostMapping("/addModel") public AjaxResult addModel(Model model){ //......... } //Modified @PostMapping("/addModel") public AjaxResult addModel(JSONObject json){ //......... Model model = JSONObject.parseObject(json.toJSONString(),Model.class); } }
2. Add method in controller
@InitBinder protected void initBinder(WebDataBinder binder) { binder.setAutoGrowNestedPaths(true); binder.setAutoGrowCollectionLimit(1024); }
Similar Posts:
- [Solved] Cannot deserialize instance of `java.lang.String` out of START_OBJECT token
- Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
- [Solved] No converter found for return value of type: class org.json.JSONObject
- How to Solve Error: Required request body is missing
- System.Data.SqlTypes.SqlNullValueException: ‘Data is Null. This method or property cannot be called on Null values.’
- [Solved] EF An error occurred while updating the entries. See the inner exception for details.
- Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter ’email’ for method parameter type String is not present]
- [Solved] net.sf.json.JSONException: java.lang.ClassCastException: JSON keys must be strings.
- Spring: How to Solve Global exception @restcontrolleradvice
- The second parameter of openfit duplicate mapping and openfit interface method is bindingresult Error