You cannot provide default value to spring path variable as of now.
You can do the following obvious thing:
@GetMapping(value = "/{locale}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getLocale(@PathVariable("locale") String locale) {
locale = locale == null? "english": locale;
return new ResponseEntity<>(locale, HttpStatus.OK);
}
But more appropriate is to use Spring i18n.CookieLocaleResolver, so that you do not need that path variable anymore:
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en"/>
</bean>