0

In my Spring Application have one Bean..

    public class SampleBean{
      private String id;
      private String name;
      private String marks;
      --------
      --------
}

And my Another Service bean Crating Property like..

List<SampleBean> list = new Array<SampleBean>();
//Setter and getters

And in my Controller class Set some values to list

And now my jsp i'm getting these values using Jquery..

<c:set var="modalAttributeName"value="MODEL1" />
<c:set var="modalAttribute"value="${requestScope[modalAttributeName]}" />
  <form:select class="select_box" path="country" id="country">
     <form:options items="${modalAttribute.list}" />
  </form:select>

It is showing entire Bean name like SampleBean@0

But i want in this Select box only SampleBean class name only..

So how to Display name using Jquery?

EDIT

i'm trying like this but empty box showing..

     <form:select class="select_box" path="country" id="country">
        <c:forEach items="${modalAttribute.list}" var="result">
            <form:options item="${result.name}" />
        </c:forEach>
    </form:select>

2 Answers 2

0

Add this list to your model attribute map. I assume you already have a model map passed into your controller method. So for example:

model.put("list", list);

If you don't have the model map passed to your method, then just another parameter: Map<String, Object> model.

Then in your JSP:

 <form:select class="select_box" path="country" id="country">
    <c:forEach items="${list}" var="result">
        <form:option value="${result.name}">
            <c:out value="${result.name}"/>
        </form:option>
    </c:forEach>
</form:select>
Sign up to request clarification or add additional context in comments.

Comments

0

a possible sulition can be render the list as JSOn from controler and catch it in a java script code making an ajax call , thus its easier to use in jquery

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.