How to make a project internationalized in Struts 2?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 00:45:34

问题


I want to make my project internationalized. I am giving support for the Spanish and Italian languages, but some of the characters from both of the languages (acute accent and grave accent characters) are not appearing properly on the UI.

Does anybody have the solution for this problem?


回答1:


Yes. You have an encoding problem. Your server gives the pages in a different encoding, as your browser thinks, and this is because international characters appear faulty.

You need to fix the settings of your webapp and your appserver, to use the better encoding (preferable utf-8).




回答2:


The framework is internationalized.

You need to add the corresponding to each locale resource bundles for the localized messages that you display via the struts tags. Use text tag or getText() to retrieve a message in the UI.

The browser language is passed with the HTTP request and framework create a locale corresponding to the browser settings. Switching locale performed via passing a special parameter request_locale to i18n interceptor that should be on your stack.

You can also configure this interceptor to accept user-defined parameters.

Normally switching to a locale persist for the session of the user. So, you don't have to pass a parameter each time on every request, but this case is also supported if needed. See how could you achieve all of the above using localization.



来源:https://stackoverflow.com/questions/20567645/how-to-make-a-project-internationalized-in-struts-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!