Announcement Announcement Module
Collapse
No announcement yet.
IllegalStateException: 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

  • IllegalStateException: Neither BindingResult nor plain target object for bean name

    Hi everyone,

    First of all i'm sorry if i write something wrong i'm french. I have some issue with a jsp page i have an error
    Code:
    javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'inscription' available as request attribute
    	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
    	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
    	org.apache.jsp.pages.views.inscription_jsp._jspService(inscription_jsp.java:105)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	org.xxx.utils.PageTitleFilter.doFilter(PageTitleFilter.java:94)
    	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:239)
    	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1072)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:808)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:726)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:636)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:545)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    controller-servlet.xml
    Code:
    	<!-- Tiles Configuration -->
    	<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="order" value="0"/>
    		<property name="requestContextAttribute" value="requestContext"/>
    		<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    		<property name="viewNames" value="page.*"/>
    	</bean>
    	
    	<!-- View Resolver -->
    	<bean id="jstlViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="order" value="1"/>
    		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    		<property name="redirectContextRelative" value="true" />
    		<property name="prefix" value="/pages/"/>
    		<property name="suffix" value=".jsp"/>
    	</bean>
    
    	<bean id="inscriptionController" class="org.xxx.web.controller.InscriptionController">
     		<property name="formView" value="views/inscription" />
    		<property name="successView" value="views/inscriptionSuccess" />
    		<property name="commandName" value="inscription" />
    		<property name="commandClass" value="org.xxx.web.entites.Utilisateur" />
    		<property name="validator">
    			<bean class="org.xxx.web.validator.InscriptionValidator" />
    		</property>
    		<property name="utilisateurService">
    			<ref bean="utilisateurService" />
    		</property>
    		<property name="inscriptionService">
    			<ref bean="inscriptionService" />
    		</property>
    	</bean>
    InscriptionController.java
    Code:
    	@Override
    	protected Object formBackingObject(HttpServletRequest request) throws Exception
    	{
    		Utilisateur user = new Utilisateur();
    		return user;
    	}
    	
    	@Override
    	protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception {
    		Map<String,List<String>> model = new HashMap<String, List<String>>();
    		/** Ajout des pays */
    		List<String> listePays = inscriptionService.listePays();
    		model.put("listePays", listePays);
    		/** Ajout des ligues */
    		List<String> listeLigue = inscriptionService.listeLigue();
    		model.put("listeLigue", listeLigue);
    		return new ModelAndView(getFormView(),"model",model);
    	}
    inscription.jsp
    Code:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
    <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
    <%@ page import="org.xxx.utils.TilesConstants" %>
    
    <tiles:insertDefinition name="<%=TilesConstants.TILES_SUB%>">
    	<tiles:putAttribute name="body" type="string">
    		<h2 class="title">Inscription</h2>
    		<p class="text">Veuillez saisir les informations vous concernant.
    		<br />Un email vous sera envoy&eacute; par la suite afin de confirmer votre inscription.
    		<br />Les champs marqu&eacute;s d'un * sont obligatoires pour que l'inscription soit valide.</p>
    		<form:form commandName="inscription" method="post">
    			...
    		</form:form>
    	</tiles:putAttribute>
    </tiles:insertDefinition>
    Thanks you all for you help

  • #2
    A little up because i can't solve this problem

    Comment


    • #3
      I usually get this when I have forgotten to add a domain object to the model.

      Code:
      ...
      model.addAttribute("inscription", new Inscription());
      
      return "form";
      The form I usually have
      Code:
      <form:form modelAttribute="inscription">
      I always pass a empty domain object to the form when I run in to that error. Hope that helps

      Comment

      Working...
      X