Spring MVC 表单提交方式为post,后台却进入了get方法

J2EE 码拜 9年前 (2015-08-12) 3458次浏览
 

在jsp页面的表单里我明明已经指明了表单提交的方式为POST:

<form id="actform" method=post action="activeEmail.do" >
					<input type="hidden" id="email" name="email" value="${account.email}">
					<input type="hidden" id="pwd" name="pwd" value="${account.pwd}">
                </form>

为甚么后台却告诉我是GET方法?

[WARN ]?? 2013-12-17 16:39:53,510 method:org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.handleHttpRequestMethodNotSupported(DefaultHandlerExceptionResolver.java:194)
Request method ""GET"" not supported
#1

5分

SpringMVC的控制器里要声明 @RequestMapping(value=”/XXX.do”, method=RequestMethod.POST) 这样的注解
你试试看
#2
没用过springMVC 帮顶
#3
@RequestMapping(value = "user/activeEmail", method = RequestMethod.POST)
    public String activeEmail(@RequestParam("email") String email,
            @RequestParam("pwd") String pwd,
            HttpSession session,RedirectAttributes model,
    		HttpServletRequest request) {
            .........
}

我都有在controller里面定义了相应的方法了,但是不知道怎么回事,没有进这个方法
因为我没有写相应的get方法,所以就报405错误了

HTTP Status 405 - Request method ""GET"" not supported

type Status report

message Request method ""GET"" not supported

description The specified HTTP method is not allowed for the requested resource.

Apache Tomcat/6.0.37
#4

10分

没进方法就是你页面表单的action里的XX.do定义错了
比如你控制器类声明了@RequestMapping(“/baseInfoChange”)
然后方法又声明了 @RequestMapping(value=”/baseInfoChangeSave.do”)
这时候你在页面form的action里要写成/baseInfoChange/baseInfoChangeSave.do
#5

回复4楼:

你没看清我的问题啊
我在jsp页面发送的是POST请求,在后台接收到的却是get请求
为什么会这样?
#6
你是通过表单提交,还是直接url访问的?
#7
通过表单提交的啊
#8

10分

<form id=”actform” method=”post” action=”activeEmail” > 这样试下
#9

5分

我在我项目的环境中测试是没有问题的
@RequestMapping(value = “/activeEmail”, method = RequestMethod.POST)
    public String activeEmail(@RequestParam(“email”) String email,
            @RequestParam(“pwd”) String pwd) {
return “”;
}

<form id=”actform” method=”post” action=”<%=request.getContextPath()%>/ceaseSell/activeEmail.do” >
                    <input type=”text” id=”email” name=”email”>
                    <input type=”text” id=”pwd” name=”pwd”>
                    <input type=”submit” value=”提交”>
</form>

#10
debug了一下
找到原因了
进了这个方法
是这个方法里面的逻辑有问题,Redirect跳转到get方法里面去了
#11
逻辑有问题,哪里出了问题?
#12
楼主,我和你遇到了一样的问题,重定向时自己跳转到get方法里去了。楼主逻辑哪里出了问题,怎么解决的?
#13
表示 也遇到这样的问题,难道post方法里不能redirect到get方法吗
#14

5分

额我还以为是post没加双引号的缘故…
#15
你控制器里面配置的地址是:user/activeEmail

你form表单里面的地址是:activeEmail.do

两个地址不一样啊

#16

5分

form 表单里面 写全路径  ,绝对是你的activeEmail.do 在项目里面有多个。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Spring MVC 表单提交方式为post,后台却进入了get方法
喜欢 (0)
[1034331897@qq.com]
分享 (0)