RestUtils { public static MultiValueMap<String, Object> toMultiValueMap(final Object obj){ return toMultiValueMap(obj, BEAN_TO_MAP_CONVERTOR); } private  RestUtils(); static BeanToMapConvertor getBeanToMapConvertor(); static boolean isRequestBodySupportedMethod(HttpMethod method); static boolean isRequestBodySupportedMethod(RequestMethod method); static boolean isOkHttp3Present(); static HttpEntity<?> createFormEntity(final Object obj); static HttpEntity<?> createFormEntity(final Object obj, BeanToMapConvertor convertor); static MultiValueMap<String, Object> toMultiValueMap(final Object obj); static MultiValueMap<String, String> toMultiValueStringMap(final Object obj); @SuppressWarnings("unchecked") static MultiValueMap<String, V> toMultiValueMap(final Object obj, BeanToMapConvertor convertor); static String propertiesToParamString(Object request); @SuppressWarnings({ "rawtypes", "unchecked" }) static String keysToParamString(Map params); static HttpHeaders createHeader(MediaType mediaType); static HttpEntity<T> createHttpEntity(T obj, MediaType mediaType); static HttpEntity<T> createHttpEntity(T obj, HttpHeaders headers); static final String CLASS_OK_HTTP_CLIENT; static final String LIST_LEFT; static final String LIST_RIGHT; static final String DOT_ACCESOR; static final String ACCEPT_CHARSET; static final HttpHeaders FORM_HEADER; static final HttpHeaders XML_HEADER; static final HttpHeaders JSON_HEADER; static final HttpHeaders TEXT_HEADER; }
@Test public void test(){ UserEntity user = new UserEntity(); user.setId(11L); user.setUserName("testUserName"); RoleEntity role = new RoleEntity(); role.setId(20L); role.setName("testRoleName"); RoleEntity role1 = new RoleEntity(); role1.setId(21L); role1.setName("testRoleName1"); user.setRoles(Arrays.asList(role, role1)); MultiValueMap<String, Object> mmap = RestUtils.toMultiValueMap(user); System.out.println("mmap:"+mmap); String paramString = ParamUtils.comparableKeyMapToParamString(mmap); System.out.println("paramString:"+paramString); Assert.assertEquals("age=0&height=0.0&id=11&roles[0].id=20&roles[0].name=testRoleName&roles[0].version=0&roles[1].id=21&roles[1].name=testRoleName1&roles[1].version=0&userName=testUserName", paramString); }