0

我正在使用 InternalResourceViewResolver 来解析视图,当我尝试执行从视图到控制器的操作时,我遇到了使用 RequestMethod.POST 的方法的问题。我收到以下错误:

11:29:34,375 WARN  [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/PostTest/home/segundaVista2] in DispatcherServlet with name 'dispatcherServlet'

我的控制器是这样的:

@Controller("CatalogController")
@RequestMapping("/home")
public class CatalogControllerImpl implements CatalogController {

    private static final String GET_PRODUCTS_VIEW = "index";

    public CatalogControllerImpl() {
    }

    @RequestMapping(method=RequestMethod.GET)
    public String getProducts(Map<String, Object> model) {

        System.out.println("Controller -> Getting products...");

        model.put("message", "Mensaje de prueba");

        System.out.println("Controller -> Finishing getting products...");

        return GET_PRODUCTS_VIEW;
    }

    @RequestMapping(value="primeraVista", method=RequestMethod.POST)
    public String primeraVista() {
        return GET_PRODUCTS_VIEW;
    }

    @RequestMapping(value="segundaVista", method=RequestMethod.POST)
    public String segundaVista() {
        return GET_PRODUCTS_VIEW + 2;
    }

}

我的观点是:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Post test</title>
    </h:head>
    <h:body>
        <form method="post" action="home/segundaVista2">
            <!--p:commandButton id="showMessage" value="showMessage" action="#{CatalogController.showMessage}" ajax="false" /-->
            Esta es la primera vista: <input type="submit" />
        </form>
    </h:body>
</html>

你有什么建议吗?

4

1 回答 1

1

您传入的 URI 是segundaVista2,但您@RequestMapping的只是segundaVista

于 2013-08-14T16:42:07.337 回答