Trabajando con netbeans 8.0.2
Mi index.jsp
Código:
mi controlador:<c:url var="addAction" value="/personas/add" ></c:url> <form:form action="${addAction}" commandName="personas" method="POST"> <table> <tr> <td> <form:label path="nombre"> <spring:message text="NOMBRE"/> </form:label> </td> </tr> <tr> <td> <input type="submit" value="<spring:message text='Add Person'/>" /> </td> </tr> </table> </form:form>
Código:
Mi error:package com.proyectito.springmvc.controller; import com.proyectito.springmvc.model.Personas; import com.proyectito.springmvc.service.PersonasService; import java.util.Map; import org.springframework.stereotype.Controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/*") public class PersonasController { private PersonasService personaService; @RequestMapping(value= "/personas/add", method = RequestMethod.POST) public String addPerson(@ModelAttribute("personas") Personas p){ this.personaService.addPerson(p); return "redirect:/index"; } }
Código:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'personas' available as request attribute root cause java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'personas' available as request attribute