Announcement Announcement Module
Collapse
No announcement yet.
Neither BindingResult nor plain target object for bean name Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neither BindingResult nor plain target object for bean name

    I have exception in my project. I can`t fix this exception.
    Code:
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'id' available as request attribute
    Code:
    public class ClientManagerImpl extends SimpleFormController{
    	ClientIpDAO clientDAO;
    
    
    	public ClientIpDAO getClientDAO() {
    		return clientDAO;
    	}
    
    	public void setClientDAO(ClientIpDAO clientDAO) {
    		this.clientDAO = clientDAO;
    	}
    	
    	  public ModelAndView onSubmit(Object command)
    	            throws ServletException {
    		  ClientIP id = (ClientIP) command;
    		  ModelAndView mav = new ModelAndView(getSuccessView(),"id",id);
    	        //mav.addObject("id", id);
    	        return mav;
    	        
    	    }
    
    	    public ClientManagerImpl() {
    	    	 setCommandClass(ClientIP.class); 
    	         setCommandName("id"); 
    	}
    
    		protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    	    	ClientIP id = new ClientIP();
    			id.setClientAlias("BLA");
    			id.setClientIP_id("100.200.3.2");
    			id.setClientPass("reer");
    	        return id;
    	    }
    
    
    
    }
    Code:
    <bean id="clientDAO" class="springapp.dao.impl.ClientIpDAOimpl">
    
        <property name="factory" ref="mySessionFactory" />  
    
    </bean>
    
    <bean name="/mainNew.htm" class="springapp.dao.manager.ClientManagerImpl" p:formView="userForm" p:successView="clientSuccess">
    
    <property name="clientDAO" ref="clientDAO" />
    
    </bean>
    Code:
    <%@ page language="java" contentType="text/html; charset=UTF-8"
    	pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jsp/include.jsp"%>
    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Hello :: Spring Application</title>
    </head>
    
    <body>
    <jsp:useBean id="id" class="springapp.dao.manager.ClientManagerImpl" /> 
    
     <c:forEach items="${model.clients}" var="client">
          <c:out value="${client.clientAlias}"/> <i>$<c:out value="${client.clientIP_id}"/></i><br><br>
        </c:forEach>
    <input type="text" name="textAlias" size="25">
    <input type="text" name="textIP" size="25">
    <input type="text" name="textPass" size="25">
    	<form:form  commandName="id"  method="POST">
    
    		<table>
    
    			<tr>
    
    				<td>User Name :</td>
    
    				<td><form:input path="clientAlias" /></td>
    
    			</tr>
    			<tr>
    
    				<td colspan="2"><input type="submit"></td>
    
    			</tr>
    		</table>
    
    	</form:form>
    </body>
    </html>

  • #2
    Can you post your Controller code also? Your Controller should be putting an entry in the Model with the name "id".

    Comment

    Working...
    X