我收到以下警告: 不支持请求方法'POST'。不支持Spring MVC-Request方法'POST':org.springframework.web.servlet.PageNotFound handleHttpRequestMethodNotSupported
控制器方法:
@Controller
public class UserServiceController {
@RequestMapping(value = "/login", method = RequestMethod.POST)
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public String login(@RequestParam Map<String,String> requestParams) throws Exception{
System.out.println(requestParams.values());
loginService.userAuthentication(requestParams.get("loginuname"), requestParams.get("loginpassword"));
System.out.println("Before return");
return "static/profile.html";
}
}
分配器一servlet.xml中
<mvc:resources mapping="/static/**" location="/WEB-INF/static/" />
的index.html
<script language="javascript" type="text/javascript">
function submitForm(){
document.login.submit();
}
</script>
<div id="login" class="login">
<form action="http://localhost:8080/SampleApp/login" name="login" method="post">
<input type="text" value = "Email" name="loginuname" id="loginuname" class="loginbasetxt">
<input type="text" value="Password" name="loginpassword" id="loginpassword" class="loginbasetxt">
<img src="static/img/tb-login-button.png" onclick="submitForm()"/>
</form>
</div>
然而,如果我会改变方法= RequestMethod.GET和相应地在登录页面,然后它会工作。
请注意,问题是在返回“static/profile.html”;
FYI profile.html的位置是WEB-INF /静态/
谢谢!
获取的警告在哪里呢?你是否将'login'中的登录信息作为请求参数提交或作为表单提交? – chrylis
你确定你的表单的URL是否正确,action属性是action =“POST”? – isah
请发布http表单,发送的请求以及控制器类的类关键字旁边的注释。 – Ralph