Spring-Test-MVC / MockServletContext - content empty in test but working on Tomcat

后端 未结 3 1967
栀梦
栀梦 2021-01-12 05:43

We\'re trying to set up Spring-Test-MVC for our Spring-MVC web app. We started out using freemarker and everything was fine. We decided against it though and are now trying

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-12 06:15

    Adding onto your edit3, essentially for JSP rendering the final call is

    RequestDispatcher requestDispatcher = httpRequest.getRequestDispacher(jspPath)
    requestDispatcher.forward(httpRequest,httpResponse)
    

    and the RequestDispatcher implementations are provided by the container (since it is dependent on how the jsp's need to be compiled, where to place the compiled jsp's etc). The Mock implementation of RequestDispatcher simply captures the forwarded JSP page, and you can only validate that the path to the JSP is what you expect it to be.

提交回复
热议问题