The below is my controller.
@Controller
@RequestMapping("/userRegistration.htm")
@SessionAttributes("user")
public class UserController {
private UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@RequestMapping(method = RequestMethod.GET)
public String showUserForm(ModelMap model)
{
User user = new User();
model.addAttribute(user);
return "userForm";
}
@RequestMapping(method = RequestMethod.POST)
public void onSubmit(@ModelAttribute("user") User user, HttpServletResponse response) {
userService.add(user);
//return "redirect:userSuccess.htm";
}
}
The problem in the above code is, in the method 'onSubmit' I am not returning anything but the webpage in the browser is lost, as well as it is not redirected to any new URL, the same URL displayed in the browser.
Please let us know, what is the issue?