Unable to load html page "addRenewalCode" after successful completion of post request. Code Structure
Controller :
@Controller
public class LoginController {
@Autowired
LoginDao loginDao;
@RequestMapping(value = { "/" }, method = RequestMethod.GET)
public String login() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("login");
return "login";
}
@RequestMapping(path = "/dynamicRenewalCodes", method = RequestMethod.POST)
public String login(@RequestParam(value = "username") String username,
@RequestParam(value = "password") String password) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("dynamicRenewalCodeList");
return "dynamicRenewalCodeList";
}
@PostMapping(value = "/addNewRenewalCode")
public String addNewRenewalCode() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("addRenewalCode");
return "addRenewalCode";
}
}
Thymeleaf Html:
<div class="form-group">
<button type="button" class="btn btn-secondary btn-lg" th:onclick="addRenewalCode()">Add Renewal Code</button>
</div>
When click on the above button in network console, status code shows 200 and in preview it shows the "addRenewalCode" html page, but the "addRenewalCode.html" page is not able load. Please help !!!