我使用的一種形式,當我點擊提交它擊中以下控制器。SpringBoot說:「請求方法‘POST’不支持
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class ViewController
{
private final static String USERNAME = "username";
private final static String PASSWORD = "password";
@RequestMapping(value = "/", method = RequestMethod.GET)
public String authenticate()
{
return "authenticate.html";
}
@RequestMapping(value = "/connector", method = RequestMethod.POST)
public String connector(final HttpServletRequest request)
{
final HttpSession session = request.getSession();
final String username = request.getParameter(USERNAME);
final String password = request.getParameter(PASSWORD);
session.setAttribute(USERNAME, username);
session.setAttribute(PASSWORD, password);
return "connectors.html";
}
}
我知道方法被擊中,因爲我已經把斷點它可是,我還是得到上述錯誤
編輯:我已經發布了整個控制器,而不僅僅是方法
EDIT2:我的HTML格式如下:
<form action="/connector" method="post" name="authentication_form">
<input type="text" name="username" id="username">
<input type="password" name="password" id="password">
<a href = "javascript:document.authentication_form.submit();" class="link-next">
Next
<i class="ico-chevron-right"></i>
</a>
</form>
我錯過了什麼?任何幫助是極大的讚賞。
發佈完整的控制器類 – Reimeus
我已經編輯我的職務,以顯示完整的類@Reimeus – MaxPower
請添加你的您是否正在使用,春季安全或任何類型的安全使用 – reos