Home > Article > Web Front-end > Detailed explanation of springmvc receiving array data submitted by jquery
This article mainly introduces the code sharing of springmvc for receiving array data submitted by jquery. It is quite good. I will share it with you here for the reference of friends in need. Hope it helps everyone.
The code shared here is related to springmvc receiving the array data submitted by jquery. The specific code is as follows:
var selectedUsers = $('#users').tagbox('getValues'); if (selectedUsers.length > 0) { $.post(appPath + "/role/users/add/", { 'systemID' : $('#systemID').combobox('getValue'), 'roleID' : roleID, 'users' : selectedUsers }, function(result, status) { if (result == 'false') { $.messager.show({ title : '角色管理', msg : '添加用户发生异常' }); } // 刷新被选择的用户 getSelectedRoleUsers(); });
selectedUsers obtained is an array, submitted with the name users
@PostMapping("/users/add/") @ResponseBody public String addUsers(String systemID, String roleID, @RequestParam(name = "users[]") String[] users) { }
Pay attention to the red part, it must be obtained with the name users[] to get the desired data.
Related recommendations:
SpringMvc file upload and download
How does Jquery+ajax+springMVC return json
SpringMVC Detailed Explanation
The above is the detailed content of Detailed explanation of springmvc receiving array data submitted by jquery. For more information, please follow other related articles on the PHP Chinese website!