【发布时间】:2023-01-14 20:59:56
【问题描述】:
我是 Spring MVC 的新手。当我打开 index.jsp 时该网站工作,但是当我尝试访问页面“springmvc/students/hi”时,它给了我 404。
@Controller
@RequestMapping("/students")
public class StudentController {
@GetMapping("/hi")
public ModelAndView sayHi(){
ModelAndView mav = new ModelAndView();
mav.addObject("message", "Hello"); // Key - Value
mav.addObject("messagebody", "This is a Test System");
mav.setViewName("hi"); // hi.jsp
return mav;
}
}
这是文件顺序:https://imgur.com/a/EwHagDs
【问题讨论】: