hi there, this is my first post...
i'm new to spring and i'm stuck in a little problem...
I've a controller with 3 methods like these:
When i go to "/" or "/list" getCustomerList() is called and i got the list of the customers;Code:@RequestMapping(value = {"","/list"}, method = RequestMethod.GET) public MyModelAndView getCustomerList() { MyModelAndView mav = new MyModelAndView(); mav.setViewName("default"); mav.addObject("component", "customers"); mav.addObject("pageTitle", "Customers Management"); mav.addObject("page", "index"); List<Customer> customersList = customerBo.list(); mav.addObject("customersList",customersList); return mav; } @RequestMapping(value = "/new", method = RequestMethod.GET) public MyModelAndView newCustomer() { MyModelAndView mav = new MyModelAndView(); mav.setViewName("default"); mav.addObject("component", "customers"); mav.addObject("pageTitle", "New Customer"); mav.addObject("page", "customer"); mav.addObject("customer", new Customer()); return mav; } @RequestMapping(value = "/save", method = RequestMethod.POST) public MyModelAndView saveCustomer(@Valid Customer customer, BindingResult result) { if (result.hasErrors()) { Message errorMessage = new Message(); errorMessage.setType(MessageType.MESSAGE_ERR); for (ObjectError err : result.getAllErrors()) { errorMessage.addText(err.getDefaultMessage()); } MyModelAndView mav = newCustomer(); mav.addObject(MessageType.MESSAGE_ERR.getType(), errorMessage); mav.addObject("customer", customer); return mav; } else { customerBo.save(customer); return getCustomerList(); } }
in this page i've a button that point to /new and that brings me to the new customer form.
Now the problem....when i save the form I validate the bean, in case of success I persist the object and then I return the getCustomerList() method, but, while the view changes, the url in the browser remains "/save"...
I'd like to display "/" or "/list"...
how can i do it?
thanks


Reply With Quote
