Home > Web Front-end > JS Tutorial > Example analysis: springmvc receives array data submitted by jquery

Example analysis: springmvc receives array data submitted by jquery

小云云
Release: 2017-12-26 15:00:49
Original
1521 people have browsed it

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();
});
Copy after login

selectedUsers gets an array and submits it under the name users

@PostMapping("/users/add/")
@ResponseBody
public String addUsers(String systemID, String roleID, @RequestParam(name = "users[]") String[] users) {
}
Copy after login

Pay attention to the red part. It must be obtained under the name users[] to get the desired data.

Related recommendations:

SpringMvc file upload and download

BootstrapTable usage backend using SpringMVC+Hibernate

SpringMVC Detailed Explanation

The above is the detailed content of Example analysis: springmvc receives array data submitted by jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template