Spring MVC bind property

I have list box in my JSP page which is getting populated by object which is passed from controller side. I want to choose some items and press DELETE button to remove some items from my black list. (Update property)

<select name="blackListSelect" id="blackListSelect" >
    <c:forEach var="entry" items="${blackList}">
        <option value='${entry.id}'>${entry.value}</option>
    </c:forEach>
</select>


public class Site
{
   int SiteId;
   List<BlackWord> blackList;

....
...
..

}

How do I update my blackList property on server side? how do I pass this object back? How should I bind updated list back to property? Could you please give me any tips or code example? Thanks!


It is not straight forward: you can't pass back the all the entries of select if you just do POST on a form. There are several ways to do what you want:

  • The POST will pass selected items. The back end code then will have to reconcile the list accordingly
  • Pass all the remaining select items in select on DELETE. The JavaScript function will have to get them.
  • 链接地址: http://www.djcxy.com/p/83496.html

    上一篇: 纯JavaScript的正确语法

    下一篇: Spring MVC绑定属性