美文网首页
SpringBoot 踩坑记1

SpringBoot 踩坑记1

作者: luke_ | 来源:发表于2018-08-08 09:46 被阅读0次

页面跳转
window.location.href = "index";

该代码的意思是跳转到 index 这个请求,SpringBoot会根据Controller中的RequestMapping找到"/index"请求,然后执行里面的内容,并不是跳转到"index.html"。


注意 controller 会自动添加controller的前缀 home (即@RequestMapping("home"))
代码如下

@Controller
@RequestMapping("home")
public class Home{
    @RequestMapping(value = "index")
    public ModelAndView index(ModelMap model) {
        return new ModelAndView("home/index",model);
    }
}

相关文章

网友评论

      本文标题:SpringBoot 踩坑记1

      本文链接:https://www.haomeiwen.com/subject/lvltbftx.html