问题 I have a method in Spring MVC with optional path variable. I am trying to test it for a scenario when optional path variable is not provided. Snippet from Controller, resource URI to invoke- @RequestMapping(value = "/some/uri/{foo}/{bar}", method = RequestMethod.PUT) public <T> ResponseEntity<T> someMethod(@PathVariable("foo") String foo, @PathVariable(value = "bar", required = false) String bar) { LOGGER.info("foo: {}, bar: {}", foo, bar); } Snippet from my test using MockMvc- //inject