Spring mvc 不支持SpringMVC请求方法“GET”?
这是一个非常简单的代码,我正在努力开始使用SpringMVC,我已经尝试了各种方法来解决这个问题,但我没有成功。代码可以正常运行以显示index.jsp,它告诉我DispatcherServlet和ViewResolver都可以正常工作,但是当我单击LoginForm以显示登录表单LoginForm.jsp以便用户可以提交用户名和密码时,我得到了以下异常Spring mvc 不支持SpringMVC请求方法“GET”?,spring-mvc,Spring Mvc,这是一个非常简单的代码,我正在努力开始使用SpringMVC,我已经尝试了各种方法来解决这个问题,但我没有成功。代码可以正常运行以显示index.jsp,它告诉我DispatcherServlet和ViewResolver都可以正常工作,但是当我单击LoginForm以显示登录表单LoginForm.jsp以便用户可以提交用户名和密码时,我得到了以下异常 Here is what I am getting when I run my code "Sep 02, 2014
Here is what I am getting when I run my code
"Sep 02, 2014 2:56:49 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleHttpRequestMethodNotSupported
WARNING: Request method 'GET' not supported"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
我真的很感谢你的帮助
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
下面是我代码的一些部分
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
这是我的控制器
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
web.xml
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
loginform.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
在春季,您不必*.html。只需使用控制器值。在views.xml中,您必须将值设置为jsp文件
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring3Example</title>
</head>
<body>
<h3>Login Form</h3>
<FONT color="blue">
<h6>User Name="UserName" and password="password"</h6>
</FONT>
<form:form action="loginform.html" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
<form:form action="/loginform" commandName="loginForm">
<table>
<tr>
<td>User Name:<FONT color="red"><form:errors
path="userName" /></FONT></td>
</tr>
<tr>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td>Password:<FONT color="red"><form:errors
path="password" /></FONT></td>
</tr>
<tr>
<td><form:password path="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>