快捷搜索: 王者荣耀 脱发

Springboot打成jar包thymeleaf报错的问题

首先看下报错:

错误状态下我们的Controller层:

@RequestMapping(value="/", method= RequestMethod.GET)
    public String home(HttpServletRequest request, Model model) {
        Account currentAccount = (Account) request.getSession().getAttribute(QexzConst.CURRENT_ACCOUNT);
        model.addAttribute(QexzConst.CURRENT_ACCOUNT, currentAccount);
        return "/home";
    }

在最后返回的时候 return "/home";

正确状态下我们的Controller层:

@RequestMapping(value="/", method= RequestMethod.GET)
    public String home(HttpServletRequest request, Model model) {
        Account currentAccount = (Account) request.getSession().getAttribute(QexzConst.CURRENT_ACCOUNT);
        model.addAttribute(QexzConst.CURRENT_ACCOUNT, currentAccount);
        return "home";
    }

在最后返回结果时: return "home";

切记不要在路径前面加“/”这个斜杠了,你在云服务器下运行肯定报500错误,找不到这个页面。

经验分享 程序员 微信小程序 职场和发展