Home >Web Front-end >JS Tutorial >How to submit array data using jquery and receive it with springmvc

How to submit array data using jquery and receive it with springmvc

php中世界最好的语言
php中世界最好的语言Original
2018-04-16 11:11:421618browse

This time I will bring you jquerySubmit arrayHow to receive data using springmvc, jquery submits array data and uses springmvc to receive itWhat are the precautions, The following is a practical case, let’s take a look.

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 gets an array, submitted under 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.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:



The above is the detailed content of How to submit array data using jquery and receive it with springmvc. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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