如何从表单中获取值:选择jsp?

时间:2021-04-09 00:03:02

This is part of a table in a jsp that shows users and role values...

这是jsp中表格的一部分,显示用户和角色值...

I can not get the actual value into the url /toggleproposalrole?id=${siteUser.id}&proposal_role=${selected} when I select one of the values in the dropdown list..... just like this: ...

当我选择下拉列表中的一个值时,我无法将实际值输入到url /toggleproposalrole?id=${siteUser.id}&proposal_role=$ {selected}中......就像这样:...

192.168.160.128:8080/toggleproposalrole?id=82&proposal_role=[USER,%20ORGANIZER,%20MANAGER]

The URL shows all the values from the dropdown list, not the one that has been selected.

URL显示下拉列表中的所有值,而不是已选择的值。

Any hint or alternative would be appreciated.

任何提示或替代方案将不胜感激。

<td>
<div class="form-group">
    <form:select path="proposalRoles" id="proposalRoles" name="proposalRoles">
        <form:option value="" label="Select" />
        <form:options items="${proposalRoles}" 
        value="${proposalRoles}" selected="${selected}"/>
    </form:select>
</div>
</td>
<td>
    <a href="${contextRoot}/toggleproposalrole?id=${siteUser.id}&proposal_role=${selected}">
        <button class="btn-u" type="button">Modificar</button>
    </a>
</td>

Thanks

1 个解决方案

#1


0  

<form:select path="proposalRoles" id="proposalRoles" name="proposalRoles">
        <form:option value="" label="Select" />
        <form:options items="${proposalRoles}" 
        value="${proposalRoles}" selected="${selected}"/>

You're passing the same data into both items and value which looks to be your list of all roles. value would only be used to set a specific value. Otherwise, you just want to leave it empty so that the selected value gets sent to the server. So maybe do this...

您将相同的数据传递到项目和值中,这些项目和值看起来是您所有角色的列表。 value仅用于设置特定值。否则,您只想将其保留为空,以便将所选值发送到服务器。也许这样做......

<form:select path="proposalRoles" id="proposalRoles" name="proposalRoles">
        <form:option value="" label="Select" />
        <form:options items="${proposalRoles}" selected="${selected}"/>
</form:select>

#1


0  

<form:select path="proposalRoles" id="proposalRoles" name="proposalRoles">
        <form:option value="" label="Select" />
        <form:options items="${proposalRoles}" 
        value="${proposalRoles}" selected="${selected}"/>

You're passing the same data into both items and value which looks to be your list of all roles. value would only be used to set a specific value. Otherwise, you just want to leave it empty so that the selected value gets sent to the server. So maybe do this...

您将相同的数据传递到项目和值中,这些项目和值看起来是您所有角色的列表。 value仅用于设置特定值。否则,您只想将其保留为空,以便将所选值发送到服务器。也许这样做......

<form:select path="proposalRoles" id="proposalRoles" name="proposalRoles">
        <form:option value="" label="Select" />
        <form:options items="${proposalRoles}" selected="${selected}"/>
</form:select>