actframework / actframework

An easy to use Java MVC server stack
http://actframework.org
Other
750 stars 126 forks source link

act post could not support Multimap type #1026

Open leeaee opened 5 years ago

leeaee commented 5 years ago

When using com.google.common.collect.Multimap as an attribute of entity, the POST method always get null of the Multimap attribute from request body. Reappear method:

  1. add Multimap type attribute in entity.
    public Multimap<String, String> permissions;
  2. add value for this objects like this:
    Multimap<String, String> multimap = ArrayListMultimap.create();
    multimap .put("admin", "admin.create");
    multimap .put("admin", "admin.update");
    multimap .put("admin", "admin.delete");
    multimap .put("user", "user.create");
    multimap .put("user", "user.delete");
  3. Output is correct
    "permissions": {
    "admin": [
    "admin.create",
    "admin.read",
    "admin.update",
     "admin.delete"
    ],
    "user": [
    "user.create",
    "user.read",
    "user.update",
    "user.delete"
    ]
    }
  4. Input Multimap parameter could not get value.
greenlaw110 commented 5 years ago

I don't see this issue could be fixed very soon. FastJSON doesn't support multimap deserizliation, and the issue was there for long time. For form field binding, app could write a binder. Once fastjson get it's part done, then I will create a builtin binder for multi-map support.