question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow AcceptHeaderLocaleResolver to fail on unsupported locales

See original GitHub issue

I have configured in 5.2.0.RELEASE:

	<beans:bean id="localeResolver" class="org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver">
		<beans:property name="defaultLocale" value="de" />
		<beans:property name="supportedLocales">
			<beans:list>
				<beans:value>cs</beans:value>
				<beans:value>de</beans:value>
				<beans:value>en</beans:value>
				<beans:value>es</beans:value>
				<beans:value>fr</beans:value>
				<beans:value>pt</beans:value>
				<beans:value>ru</beans:value>
			</beans:list>
		</beans:property>
	</beans:bean>

I would like the system to use the default locale if and only if the Accept-Language header has not been provided. In the case a user sends Accept-Language: pl, da I want the resolver to return 400 because neither Polish not Danish is supported.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
snicollcommented, Dec 30, 2019

Good catch!

0reactions
izeyecommented, Dec 30, 2019

Based on the “status: declined” label, this appears to be meant to be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AcceptHeaderLocaleResolver error - java - Stack Overflow
AcceptHeaderLocaleResolver will resolve the Locale from the request (using the accept header) and that's it. There is no way to set its locale...
Read more >
Cannot change HTTP accept header - use a ... - Mkyong.com
UnsupportedOperationException : Cannot change HTTP accept header - use a different locale resolution strategy ...AcceptHeaderLocaleResolver.
Read more >
AcceptHeaderLocaleResolver (Spring Framework 6.0.2 API)
LocaleResolver implementation that simply uses the primary locale specified in the Accept-Language header of the HTTP request (that is, the locale sent by ......
Read more >
Cannot change HTTP accept header ... - ConcretePage.com
Hi, I am facing an error while creating my Spring MVC internationalization application. Any Clue? java.lang.UnsupportedOperationException: ...
Read more >
Spring REST Handle locale change - iTecNote
I'm trying to handle locale change in a Spring 3 REST application. ... mockMvc.perform( get("/error/npe").headers(httpHeaders) .accept(MediaType.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found