没有找到带有URI的HTTP请求的映射 - 在Spring 3.2.4中

时间:2015-10-08 12:49:03

标签: spring spring-mvc url-mapping

我有这个控制器:

...
    @RequestMapping(value = "/accounts/manageaccount.do", method = RequestMethod.GET)
    public String initForm(HttpServletRequest request, Model model) {

        model.addAllAttributes(getModel(request));

        return "registerAccountView";
    }


    @RequestMapping(value = "/accounts/saveaccount.do", method = RequestMethod.POST)
    public String saveaccount(HttpServletRequest request, Model model) {

        model.addAllAttributes(getModel(request));

        return "registerAccountView";
    }
... 

当我将此URL放入浏览器

时,控制器的映射效果很好
http://127.0.0.1:7001/devices/accounts/manageaccount.do

然后我有这个jsp

<form method="post" action="saveaccount.do">
</form>

但是当我提交时我得到了这个奇怪的错误

URL: /devices/accounts/saveaccount.do
???error404.error??? 

1 个答案:

答案 0 :(得分:0)

确保web-xml中的servlet映射已配置为处理.do个请求:

<servlet-mapping>
  <servlet-name>yourServletName</servlet-name>
  <url-pattern>*.do</url-pattern>
</servlet-mapping>