spring - How to set servlet path for every request through MockMvc -
Is it possible to set servlet path for all requests (receiving, posting, inserting, deleting) that Go through MockMVC?
The spring transmission servlet is mapped to / rest / *, but in my testing, I have to remove the rest in the URL otherwise the spring test does not recognize the controller.
@ Sotirios:
anything is possible:
Maywvetsstes public class {private Mokmvisi Mokmvisi; @Before public void setup () {mockMvc = standaloneSetup (New AccountController ()) .defaultRequest (find ( "/") .contextPath ( "/ app"). ServletPath ( "/ main") .accept (MediaType.APPLICATION_JSON). }
}
but I may be surprised how to set servlet path for all requests. it is only possible to define servletPath with standaloneSetup
"itemprop =" text "> I have had problems with ServletException (" Circular View Path ... ") which is only real In deployment but with MockMvc Hama Sector has never tests.
The problem is that a method was not annotated with @ResponseBody. Test work as well there was an empty servlet path it 'servletPath / callPath' so it took a VIEWNAME resolution to ServletException did not throw different from 'callPath'. so how do I deploy applications and g is the closest raising test failed at issue needed to servletPath set on request with our tests annotations Forgets
.defaultRequest (found ("/"). ServletPath ("/ main"))
Worked for me like a magic, then in question The answer works.
Comments
Post a Comment