問題描述
Struts 2 動作調用丟失 xwork i18n 語言設置 (Struts 2 action call loses the xwork i18n language setting)
我在表單上調用了一個函數“foo.action?request_locale=en”。該頁面上有一個 xwork‑validation,我希望在給定的語言中得到一個驗證錯誤。我得到的是芬蘭語頁面 ‑ 我的瀏覽器默認語言 ‑ 我希望有一個英文頁面。
如何更改 jsp 頁面上使用的語言(這就是 request_locale 的來源)所以我的表單中調用的操作將顯示為所選語言而不是瀏覽器默認語言?
一些規範:struts.xml 有一行,因為我的操作位於 fi.foo.action 目錄和 i18n fi/foo/package_en.properties 和此類文件中的資源。
驗證器位於 fi.foo.action 文件夾中的 barAction‑foo‑validation.xml 類文件中。
fi =芬蘭語
## 參考解法 #### 方法 1:
It sounds like the i18n
interceptor is not configured for your action's interceptor stack. The i18n
interceptor is defined fourth in the defaultStack
. Make sure you are not overriding the stack for your action. If it appears to be configured, then try setting a breakpoint in the intercept
method of the I18nInterceptor
to confirm that it is being invoked. Otherwise, what you have should work.
(by mico、Steven Benitez)