So I've got a PersonController
With my servlet.xmlCode:@Controller @RequestMapping("/person/**") public class PersonController { String dateFormat = "yyyy-MM-dd"; protected Log log = LogFactory.getLog(this.getClass()); @Autowired private PersonService personService; private Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); @RequestMapping(value = "person/{id}", method = RequestMethod.GET) public String show(@PathVariable("id") Long id, ModelMap modelMap) { Assert.notNull(id, "Identifier must be provided."); if(log.isDebugEnabled()) { log.debug("Showing person with id: " +id); } modelMap.addAttribute("person", personService.find(id)); return "person/show"; } @RequestMapping(value = "person", method = RequestMethod.GET) public String list(ModelMap modelMap) { if(log.isDebugEnabled()) { log.debug("Listing all persons"); } modelMap.addAttribute("people", personService.findAll()); return "person/list"; } @RequestMapping(value = "person/{id}", method = RequestMethod.DELETE) public String delete(@PathVariable("id") Long id, ModelMap modelMap) { Assert.notNull(id, "Identifier must be provided."); try { personService.remove(personService.find(id)); } catch (DataIntegrityViolationException dive) { modelMap.addAttribute("integrityViolation", "The person is connected to another domain object. <br/>" + "Remove the person from this object and then try again"); } return "redirect:/person"; } @RequestMapping(value ="person/form", method = RequestMethod.GET) public String form(ModelMap modelMap) { if(log.isDebugEnabled()) { log.debug("Creating new Person"); } modelMap.addAttribute("person", new Person()); return "person/create"; } @RequestMapping(value = "person", method = RequestMethod.POST) public String create(@ModelAttribute("person") Person person, BindingResult result) { Assert.notNull(person, "Person must be provided"); for(ConstraintViolation<Person> constraint : validator.validate(person)) { result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage()); } if(result.hasErrors()) { return "person/create"; } personService.persist(person); return "redirect:/person/" +person.getId(); } @RequestMapping(value = "person/{id}/form", method = RequestMethod.GET) public String updateForm(@PathVariable("id") Long id, ModelMap modelMap) { Assert.notNull(id, "Identifier must be provided."); modelMap.addAttribute("person", personService.find(id)); return "person/update"; } @RequestMapping(method = RequestMethod.PUT) public String update(@ModelAttribute("person") Person person, BindingResult result) { Assert.notNull(person, "Person must be provided."); for(ConstraintViolation<Person> constraint : validator.validate(person)) { result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage()); } if(result.hasErrors()) { return "person/update"; } personService.merge(person); return "redirect:/person/" +person.getId(); } @InitBinder public void initBinder(WebDataBinder binder, WebRequest request) { binder.registerCustomEditor(Person.class, new PersonEditor(personService)); binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat(dateFormat), false)); }
This was working, then I wanted to add Spring Security to the mix. So I add the 3.0.0.M1 jar files to my local repo and add the dependency, I now have the security configured, but the mappings to /person/** seems to have gone away.Code:<context:component-scan base-package="com.isharelib.library" /> <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key=".DataAccessException">dataAccessFailure</prop> <prop key=".lang.Exception">uncaughtException</prop> </props> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/> <!-- Maps request paths to flows in the flowRegistry; e.g. a path of /wizard looks for a flow with id "wizard" --> <!-- Maps request paths to @Controller classes; e.g. a path of /person looks for a controller named PersonController --> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
I can still do @RequestMapping("/register") for a RegisterController and see the mapping working, but the PersonController throws the following error when requesting appname/person:
[CODE]
** Root cause is: No matching handler method found for servlet request: path '/person', method 'GET', parameters map[[empty]] org.springframework.web.servlet.mvc.multiaction.No SuchRequestHandlingMethodException: No matching handler method found for servlet request: path '/person', method 'GET', parameters map[[empty]] at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter$ServletHandlerMethodRe solver.resolveHandlerMethod(AnnotationMethodHandle rAdapter.java:498) at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:349) at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:342)
[CODE]
Any suggestions as to where I go wrong? Been racking my brains trying to find the difference between this and what I've got successfully working from the http://stsmedia.net finance application


Reply With Quote
