我想将多个角色传递给 servlet
var params = {
username : username,
password : password
};
var roles = [];
var role = $('#role').val();
if(role.length > 1){
for(var i = 0;i < role.length;i++){
roles[i] = role[i]
}
}
else{
params.role1 = role[0] ;
}
如何执行此操作以使结果看起来像
var params = {
username : username,
password : password,
role1 : role1,
role2 : role2,
roleN : roleN,
};