title: Sending form data in Spring controller without using annotation
body: <p>I want to send form input data in controller without using annotation. </p>
  
  <p>In this code I'm trying to get the <code>employeeNo</code>, <code>empName</code>, <code>deptNo</code> form the jsp file in which I have used Spring <code>&lt;form:form&gt;</code>, <code>&lt;form:input&gt;</code> tags but as I try to get value, it is not getting the value and it throws an exception:</p>
  
  <pre><code>java.lang.IllegalStateException: Neither BindingResult nor plain target object 
  for bean name 'command' available as request attribute 
  </code></pre>
  
  <p>My <strong>controller</strong>:</p>
  
  <pre><code>package com.nousinfo.tutorial.controllers;
  
  import java.util.List;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.springframework.dao.EmptyResultDataAccessException;
  import org.springframework.web.servlet.ModelAndView;
  import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
  
  import com.nousinfo.tutorial.service.impl.EmployeeServiceImpl;
  import com.nousinfo.tutorial.service.model.EmployeeBO;
  
  public class SearchEmployeeController extends MultiActionController {
      private EmployeeServiceImpl employeeServiceImpl;
  
      public void setEmployeeServiceImpl(EmployeeServiceImpl employeeServiceImpl) {
          this.employeeServiceImpl = employeeServiceImpl;
      }
  
      public ModelAndView searchByEmpNo(HttpServletRequest request,
              HttpServletResponse response) throws Exception {
          EmployeeBO empDetails = null;
          try {
              if (employeeServiceImpl.getEmployee(Long.parseLong(request
                      .getParameter("employeeNo"))) != null) {
                  empDetails = employeeServiceImpl.getEmployee(Long
                          .parseLong(request.getParameter("employeeNo")));
              }
          } catch (EmptyResultDataAccessException e) {
              return new ModelAndView("successSingleEmp", "empDetails",
                      empDetails);
          }
          return new ModelAndView("successSingleEmp", "empDetails", empDetails);
      }
  
      public ModelAndView searchByEmpName(HttpServletRequest request,
              HttpServletResponse response) throws Exception {
          List&lt;EmployeeBO&gt; listEmployeeBO = employeeServiceImpl
                  .findEmployees(request.getParameter("empName"));
          return new ModelAndView("successMultipleEmps", "listEmployeeBO",
                  listEmployeeBO);
      }
  
      public ModelAndView searchByDeptNo(HttpServletRequest request,
              HttpServletResponse response) throws Exception {
          List&lt;EmployeeBO&gt; listEmployeeBO = employeeServiceImpl
                  .getAllEmployeeByDeptid(request.getParameter("deptNo"));
          return new ModelAndView("successMultipleEmps", "listEmployeeBO",
                  listEmployeeBO);
      }
  
  }
  </code></pre>
  
  <hr>
  
  <p>My <strong>jsp</strong> file: </p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt;
  
  &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;fmt:setBundle basename="ApplicationResources" /&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Employee Search Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form:form action="search.spring" method="post"&gt;
          &lt;table border="0"&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;form:label path="employeeNo"&gt;Employee_ID&lt;/form:label&gt; &lt;form:input
                          path="employeeNo" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="method" value="FindById" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;form:label path="empName"&gt;Employee_Name&lt;/form:label&gt; &lt;form:input
                          path="empName" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="method" value="FindByName" /&gt;&lt;/td&gt;
              &lt;/tr&gt;    
              &lt;tr&gt;
                  &lt;td&gt;&lt;form:label path="deptNo"&gt;Employee_Name&lt;/form:label&gt; &lt;form:input
                          path="deptNo" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="method" value="FindByDeptNO" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2" align="center"&gt;&lt;font size=3&gt;For
                          Searching the employees by&lt;b&gt;Employee Name&lt;/b&gt;&lt;br /&gt;you can use %
                          match all the records with the given pattern
                  &lt;/font&gt;&lt;br /&gt; &lt;font size="2"&gt; &lt;i&gt;e.g &lt;b&gt; for search by&lt;/b&gt;EmployeeName&lt;br /&gt;
                              matches alL the employees whose name starts with character &lt;b&gt;S&lt;/b&gt;&lt;/i&gt;&lt;/font&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>My <strong>xml</strong> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"&gt;
      &lt;import resource="/services-context.xml" /&gt;
      &lt;bean id="searchController"
          class="com.nousinfo.tutorial.controllers.SearchEmployeeController"&gt;
          &lt;property name="employeeServiceImpl" ref="employeserviceImpl" /&gt;
          &lt;property name="methodNameResolver" ref="methodNameResolver" /&gt;
      &lt;/bean&gt;    
  
      &lt;bean id="myurlmapping"
      class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
          &lt;property name="mappings"&gt;
              &lt;props&gt;
                  &lt;prop key="search.spring"&gt;searchController&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;    
  
      &lt;bean id="methodNameResolver"
          class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"&gt;
          &lt;property name="paramName" value="method" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- configuring BeanNameViewResolver --&gt;
      &lt;bean class="org.springframework.web.servlet.view.BeanNameViewResolver"&gt;&lt;/bean&gt;
  
      &lt;!-- configuring exception Resolver --&gt;
      &lt;bean
          class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"&gt;
          &lt;property name="exceptionMappings"&gt;
              &lt;props&gt;
                  &lt;prop key="org.springframework.dao.DAOException"&gt;dberrorView&lt;/prop&gt;
                  &lt;prop key="java.lang.NumberFormatException"&gt;notANumber&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;!-- configuring views required to render the view for /search.spring --&gt;
      &lt;bean name="successSingleEmp" class="org.springframework.web.servlet.view.JstlView"&gt;
          &lt;property name="url" value="/WEB-INF/EmployeeDetail.jsp" /&gt;
      &lt;/bean&gt;
      &lt;bean name="successMultipleEmps" class="org.springframework.web.servlet.view.JstlView"&gt;
          &lt;property name="url" value="/WEB-INF/EmployeeList.jsp" /&gt;
      &lt;/bean&gt;
      &lt;bean name="dberrorView" class="org.springframework.web.servlet.view.JstlView"&gt;
          &lt;property name="url" value="/WEB-INF/DBError.jsp" /&gt;
      &lt;/bean&gt;
      &lt;bean name="notANumber" class="org.springframework.web.servlet.view.JstlView"&gt;
          &lt;property name="url" value="/WEB-INF/NotANumberError.jsp" /&gt;
      &lt;/bean&gt;
      &lt;!-- CONFIGURING THE MEASSAGE RESOURCES FOR THIS APPLICTION CONTEXT --&gt;
      &lt;bean id="messageSource"
          class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
          &lt;property name="basename" value="/com/nousinfo/resources/ApplicationResources" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>