2

私はSpring MVCプロジェクトに取り組んでいます。ユーザーを認証するために、フォームを送信して同じjspページで処理しようとしています。

コントローラーに組み込まれた Web サービスを ajax リクエストで呼び出してユーザーを認証しましたが、今回は Ajax を使用せずにそれを行うために、このエラーが発生しましたRequest method 'POST' not supported

これが私のコードです:

フォーム

<form action="/gethealthy/isuser" method="post">
  <input type="text" name="username" placeholder="Username" />
  <input type="password" name="password" placeholder="Password" />
  <button type="submit">Sign In</button>
</form>

JSP コード

if (request.getParameter("username") != null) {  
      HomeController aHomeController = new HomeController();
      String username = request.getParameter("username");
      String password = request.getParameter("password");
      String result = aHomeController.isUser(username, password);
      if (aHomeController.isUser(username, password)) {
        String redirectURL = "project/dashboard";
        response.sendRedirect(redirectURL);
      } else {
            out.print("Wrong credentials");
      }
4

1 に答える 1

2

次のようにコントローラーをマップする必要があります。

@RequestMapping(value="/", method = RequestMethod.POST)
于 2013-10-09T11:01:47.683 に答える