Is it possible to set the servlet path for all requests (get, post, put, delete) that go through MockMvc?
The Spring dispatch servlet is displayed in / rest / * But in my test I need to remove the / rest part in the url, otherwise the Spring test will not recognize the controller.
EDIT
@Sotirios:
Something is possible, for example:
public class MyWebTests { private MockMvc mockMvc; @Before public void setup() { mockMvc = standaloneSetup(new AccountController()) .defaultRequest(get("/") .contextPath("/app").servletPath("/main") .accept(MediaType.APPLICATION_JSON).build();
}}
But I'm wondering how to set the servlet path for all requests. Above the code is http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/testing.html .
Or can you only define servletPath using standaloneSetup?
ServletException ( "Circular view path..." ), , MockMvc.
, @ResponseBody. , , viewName "servletPath/callPath", "callPath", ServletException. , servletPath , , , , .
.defaultRequest(get("/").servletPath("/main"))
. , .
Source: https://habr.com/ru/post/1527371/More articles:Reserved EC2 instance. 24 copies working 1 hour (at the same hour), equal to 1 instance working 24 hours? - amazon-web-servicesHow to track EXIT / ENTER / HOVER with a mouse over a composite? - javaThe login page is displayed even if the user is already registered - pythonJointJS: Hello World example not working - javascriptHello world is not working properly in html with jointjs? - javascriptReplace repeated char with something else in the line - c #newbie: hello world using jointjs - jointjsNull Derived Optimization - c ++Cannot debug qt application - debugging completed - debuggingHow to access JSON data in a branch template? - jsonAll Articles