1

I have a problem converting the following request URL:

entity.name=Test&entity.window[0].size=1&entity.windows[1].size=2

to the following JavaBean:

public class House {
    private String nome;

    private Set<Window> windows;

    // ... getters and setters ...
}

public class Window {
    private int size;

    // ... getters and setters ...
}

I get this error when I use BeanUtils.populate:

Property 'windows' is not indexed on bean class 'class House'

I think this problem occurs because Sets don’t have a known order to follow. So I can’t map values with indices like [0]...[1]...[2]. For my purpose, for converting request params to java.util.Set attributes, can I continue using BeanUtils with some adjustments or do I have to pick another library (which one)?

4

0 回答 0