Spring MVC multiple selection using backend bean -
Spring MVC multiple selection using backend bean -
i creating web application in spring mvc using spring form capabilities.when submit jsp form,i getting info string array multiple selection box on controller,and stores in database.when user edit records how can display selected alternative items in multiple selection box.
this map used fill multiple selection box.
map mp = new hashmap(); mp.put("111", "test1"); mp.put("112", "test2"); mp.put("113", "test3"); mp.put("114", "test4"); mv.addobject("cat", mp);
this map user seleted alternative list ,fetched db.
map selmap = new hashmap(); selmap.put("111", "test1"); selmap.put("114", "test4"); mv.addobject("selcat", selmap);
how can show test1 , test4 selected on edit page in same order. need result in format.
i give illustration using spring annotations: work referencedata form.
@modelattribute("cat") public list<string> referencedata(){ map mp = new hashmap(); mp.put("111", "test1"); mp.put("112", "test2"); mp.put("113", "test3"); mp.put("114", "test4"); homecoming mp; }
now can select info values in multiple drop downwards as
@requestmapping(method=requestmethod.get) public string showform(modelmap map){ studentcommand command =new studentcommand(); map selmap = new hashmap(); selmap.put("111", "test1"); selmap.put("114", "test4"); command.setcat(selmap); map.addattribute("command", command); homecoming "studentregistration"; }
jsp
<form:select multiple="true" path="cat" items="${cat}" itemlabel="cat" itemvalue="something" />
spring-mvc
Comments
Post a Comment