mercredi 30 mars 2016

Read values of checkboxes when the value has spaces in java /servlets

I have Check boxes in my Jsp who string value is not one word i.e two or three words:

<tr>
            <td> Change Password</td>
            <td><input type="checkbox" name="admin" value="Change Password" /></td>
        </tr>
         <tr>
            <td> Add User</td>
            <td><input type="checkbox" name="admin" value="Add User" /></td>
        </tr>
        <tr>
            <td> Modify Workclass</td>
            <td><input type="checkbox" name="admin" value="Modify Workclass" /></td>
        </tr>

In my servlet I am picking the values as such:

 String[] adminresources = request.getParameterValues("admin");
if (adminresources.length > 0) {
                for (String admin : adminresources) {
                    System.out.println(admin);
                }
            }

My Output Prints only the First Work of each value i.e:

Change
Add
Modify

I do not have the liberty to change the values as they are fetched from an external database (Not displayed in my example). How do I get the full values or what is it that I am doing wrong that I am getting only the first word?




Aucun commentaire:

Enregistrer un commentaire