当前位置:编程学习 > JAVA >>

Spring MVC 表单提交方式明明已经指明为post,为什么后台却进入了get方法里?

在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
--------------------编程问答-------------------- SpringMVC的控制器里要声明 @RequestMapping(value="/XXX.do", method=RequestMethod.POST) 这样的注解
你试试看 --------------------编程问答-------------------- 没用过springMVC 帮顶 --------------------编程问答--------------------

@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
--------------------编程问答-------------------- 没进方法就是你页面表单的action里的XX.do定义错了
比如你控制器类声明了@RequestMapping("/baseInfoChange")
然后方法又声明了 @RequestMapping(value="/baseInfoChangeSave.do")
这时候你在页面form的action里要写成/baseInfoChange/baseInfoChangeSave.do --------------------编程问答--------------------
引用 4 楼 dyboy0822 的回复:
没进方法就是你页面表单的action里的XX.do定义错了
比如你控制器类声明了@RequestMapping("/baseInfoChange")
然后方法又声明了 @RequestMapping(value="/baseInfoChangeSave.do")
这时候你在页面form的action里要写成/baseInfoChange/baseInfoChangeSave.do

你没看清我的问题啊
我在jsp页面发送的是POST请求,在后台接收到的却是get请求
为什么会这样? --------------------编程问答-------------------- 你是通过表单提交,还是直接url访问的? --------------------编程问答-------------------- 通过表单提交的啊 --------------------编程问答-------------------- <form id="actform" method="post" action="activeEmail" > 这样试下 --------------------编程问答-------------------- 我在我项目的环境中测试是没有问题的
@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> --------------------编程问答-------------------- debug了一下
找到原因了
进了这个方法
是这个方法里面的逻辑有问题,Redirect跳转到get方法里面去了
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,