Bootstrap

thymeleaf form表单的th:action链接一定要加/

<form class="form-signin" action="dashboard.html" th:action="@{user/login}" method="post">
@Controller
public class LoginController {

    @PostMapping("user/login")
    public String login(Map<String, Object> map,
                      @RequestParam("username") String username,
                      @RequestParam("password") String password) {
        if (!StringUtils.isEmpty(username)&&"123".equals(password)){
            return "redirect:/main.html";
        }
        else {
            map.put("message","用户名或密码错误");
            return "login";
        }
    }
}

如果不加

我提交表单路径就会变成user/user/login,多一个user,反正就是要加,才对

;