李_某人 2020-04-13 16:07 采纳率: 0%
浏览 982

Thymeleaf表单提交Request method 'POST' not supported

最近在学习使用Thymeleaf,想使用表单向后台提交数据时,遇到了一些问题

###表单

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Title</title>
</head>
<body>
        <form th:action="@{/user/register}" method="post">
             <a>ID:<input type="text" name="userId"><br/></a>
           <a>昵称: <input type="text" name="nickname" ><br/></a>
            <a>密码:<input type="password" name="password" ></a>
            <input type="submit" value="提交">
        </form>

</body>
</html>

###Controller

@Controller
@RequestMapping("/user")
public class UserController {
    @PostMapping("/register")
    public String login(User user){
        System.out.println(user);
        return "/success.html";
    }
}

###错误

WARN 2384 --- [nio-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]
  • 写回答

1条回答 默认 最新

  • dabocaiqq 2020-04-13 16:09
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料