I have a controller class with a RequestMapping method. This method is not being rendered. I do not see any errors in my console. I am sure my request is being mapped correctly tried with some print statements. But the view is not rendering also there is no error in the log. I just get an HTTP 404 in browser. Not sure what is wrong when other views are being rendered properly. I have read the following question SpringMVC giving 404 returning a view
but does not help.
Here is the request mapping method. Not sure what is wrong or how to debug it? All my jsp files are in one directory. I also have a public default constructor in my Controller. But something else could be wrong with my controller which I don’t see yet. Here is the link to the more detailed code if you want more details.
https://github.com/C4G/V2V/blob/cbc4a8d9e904ab1f5bf47b9550a0879ccff33b01/src/controller/TestResultsController.java
@RequestMapping(value = "/editTestResultFormGenerator", method = RequestMethod.GET)
public ModelAndView editTestResultFormGenerator(HttpServletRequest request,
Model model,
@RequestParam(value="collectionNumber", required=false) Long collectionNumber,
@RequestParam(value="collectionId", required=false) Long collectionId) {
TestResultBackingForm form = new TestResultBackingForm();
ModelAndView mv = new ModelAndView("editTestResultForm");
Map<String, Object> m = model.asMap();
m.put("refreshUrl", getUrl(request));
m.put("existingTestResult", false);
if (collectionId != null) {
form.setId(collectionId);
TestResult testResult = testResultRepository.findTestResultByCollectionId(collectionId);
if (testResult != null) {
form = new TestResultBackingForm(testResult);
m.put("existingTestResult", true);
}
else {
form = new TestResultBackingForm();
}
}
addEditSelectorOptions(m);
m.put("editTestResultForm", form);
m.put("refreshUrl", getUrl(request));
// to ensure custom field names are displayed in the form
m.put("testResultFields", utilController.getFormFieldsForForm("TestResult"));
System.out.println(m);
mv.addObject("model", m);
return mv;
}
Found the problem. With Eclipse autocomplete I chose the wrong ModelAndView class.
I should have chosen.
whereas I chose
That explains it.