Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'
时间: 2023-11-28 15:27:29 浏览: 72
This error occurs when there is an attempt to assign a string value to a variable of type Long. In Java, a Long is a wrapper class for the primitive type long, and it can only hold numeric values. Therefore, if a string value is assigned to a Long variable, the conversion fails, resulting in this error.
To resolve this issue, you need to ensure that the value being assigned to the Long variable is a numeric value. If you are reading the value from a file or database, ensure that the value is stored as a numeric data type. If the value is entered by a user through a form, you can use validation to ensure that only numeric values are accepted. You can also use the Long.valueOf() method to convert a string to a Long value explicitly.
阅读全文