I'm adding a Path variable
to receive value sent by URL. And this is my controller.
@Controller
@RequestMapping("/user")
public class UserController {
@RequestMapping(value = "/list/{field}", method = RequestMethod.GET)
public void userList(Model model, @PathVariable("field") String field) {
List<Users> userList = userDAO.searchAll();
System.out.println("Condition "+field);
model.addAttribute("userList", userList);
}
}
And this is my folder structure for jsp
.
Please help me to find out what is wrong here.
Thanks.
Edit : And also is there any chance that I can send empty path variable ex: http://localhost:8080/mvcquick/user/list
and return to the same method?
system is looking for mvcquick/WEB-INF/jsp/user/list/n.jsp
.
I dont see this file.
Please try this:
@Controller
@RequestMapping("/user")
public class UserController {
@RequestMapping(value = "/list/{field}", method = RequestMethod.GET)
public String userList(Model model, @PathVariable("field") String field) {
List<Users> userList = userDAO.searchAll();
System.out.println("Condition "+field);
model.addAttribute("userList", userList);
return "user/list"; // added line. Alos return type to String
}