【问题标题】:Tomcat 404 Error While Accessing To a Page访问页面时 Tomcat 404 错误
【发布时间】: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

【问题讨论】:

    标签: java tomcat


    【解决方案1】:

    我认为 localhost:8080/students/hi 是有效路径。 请试试这个。

    【讨论】:

    • 它没有工作,虽然我只是将 Tomcat 版本从 10.1.5 更改为 9.0.71,并且 springmvc/students/hi 现在正在工作。
    • 很高兴听你这样说
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-10
    • 2018-01-19
    • 1970-01-01
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    相关资源
    最近更新 更多