Note that there are some explanatory texts on larger screens.

plurals
  1. POspring:bind error using in a List
    primarykey
    data
    text
    <p>I have a list containing users. I am trying to print it in JSP but some how I am not able to get it to print it. Getting this exception <code>HTTP Status 500 - javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'users[0]' available as request attribute</code></p> <p>Code in JSP</p> <pre><code>&lt;c:forEach items="${users}" var="user" varStatus="status"&gt; &lt;spring:bind path="users[${status.index}].name"&gt; &lt;c:out value="${status.value}" /&gt; &lt;/spring:bind&gt; &lt;/c:forEach&gt; </code></pre> <p>Controller</p> <pre><code>ModelAndView modelAndView = new ModelAndView("go_some_JSP_page"); List&lt;UserEntity&gt; users = userManager.getAllObjects(); modelAndView.addObject("users", users); </code></pre> <p>BTW, UserEntity has name field. If I remove the binding and try to print the <code>user.name</code> using <code>&lt;c:out value="user.name" /&gt;</code> it prints the value</p> <p>Where am I going wrong and what do I need to do? Thanks</p> <p>Not working code below. [I have to invoke formatting on field @NumberFormat so have to try it using <code>status</code> variable]</p> <pre><code>&lt;spring:bind path="user.name"&gt; &lt;c:out value="${status.value}" /&gt; &lt;/spring:bind&gt; </code></pre> <p>Gets this error --> <code>javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'user' available as request attribute</code></p> <p>So added a bean binding and then I get empty table :(. I believe thats because the instance is empty. So this does not seems like a right approach.</p> <pre><code>@ModelAttribute("user") public UserEntity userEntityBinding() { return UserEntity.newInstance(); } </code></pre> <p>A working code exists at <a href="https://github.com/hth/StatusInvoke.git" rel="nofollow">https://github.com/hth/StatusInvoke.git</a></p> <p>Let me know if you face any problem deploying it. </p> <p>This question has been solved. Thanks for looking at it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload