0

使用 Spring 3 MVC,如果我使用 GET 方法来解析 JSP,它可以正常工作。

@RequestMapping(value="/my_profile", method = RequestMethod.GET)
public String saveMethod(@ModelAttribute("myBasicInfoForm") MyBasicInfoForm myBasicInfoForm,  HttpServletRequest request) throws ServiceException{
    return  "/testmyprofile";
}

我通过控制器中的另一种方法调用 saveMethod(),如下所示:

@RequestMapping(value="/updateProfile", method = RequestMethod.POST)
public String updateProfile(@ModelAttribute("myForm") MyForm myForm, HttpServletRequest request){ logger.debug("<-- log message"); return "redirect:/my_profile"; } 

该方法由 HTML 表单调用:

<form:form id="ss_fp_basic_info" action="updateProfile" modelAttribute="myBasicInfoForm" method="post">

但是如果我更改为 POST 方法,我会收到以下错误,如果您能提供帮助,不胜感激:

    [6/20/12 11:23:36:118 EDT] 0000001f SystemOut     O 
[ERROR,BaseController] BaseController - handleException
    org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:623)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
4

0 回答 0