In a project where struts2 is applied, the following error is returned when you click Submit label on a page:
The
Requested list
Key 'role' cocould not be resolved as a collection/array/MAP/enumeration/iterator
Type
Check the prompt. The error message is a select tag, but the page is displayed as normal D. After troubleshooting, the action configuration related to this page is in the struts Configuration: error --> this page, that is, if an error is submitted, the page will still be returned. Because the Select data source is a request object, if an error is returned, no data is returned.
Summary:
The cause of this error may be as follows:
1. An error occurred when you first entered the interface because the set in list = "Roles" is empty, resulting in an error.
The solution is simple, and the list cannot be empty.
2. When you first enter the interface, the list contains data. When you click the submit button, the data is submitted to the background, if the verification framework is configured or the validate method is written in the action, the verification fails. If no action is taken, the input is directly returned and the interface is specified to be returned.
At this time, the list in the checkboxlist is lost, leading to the above error (this error prompt is unfriendly and is considered a class conversion error)
The solution is to put the list initialization work in the prepare interceptor, because prepare is executed before the validate interceptor, that is, the prepareble interface is implemented: