SPRINGMVC internationalization Setup appears cannot change HTTP accept Header-use A different locale resolution strategy bug

Source: Internet
Author: User
Tags i18n

The cannot change HTTP accept Header-use A different locale resolution strategy bug occurs when the system learns the SPRINGMVC process and exercises.

Internationalization needs to meet three needs

1. Localize time, values, labels, etc. on the page

2. Need to get the internationalized resource file locale corresponding message from the bean

3. You can toggle the locale dynamically via hyperlinks

Implementation method:

First configure the resource file

I18n_zh_cn.properties Chinese configuration file

i18n.user=\u7528\u6237\u540d
i18n.password=\u5bc6\u7801 (here is the conversion of Chinese to ASCII code)

I18n_en_us.properties English configuration file

I18n.user=user
I18n.password=password

Requirements 1 Implementation

Requirements 2 Implementation

Requirement 3 solution requires configuration of Sessionlocalresolver and Localchangeinterceptor

Sessionlocaleresolver is to save the locale object in the session for later access

My problem is sessionlocaleresolver here, when configuring this bean, the ID must be localeresolver, otherwise it will appear I this bug

SPRINGMVC internationalization Setup appears cannot change HTTP accept Header-use A different locale resolution strategy bug

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.