Struts 2操作调用丢失xwork i18n语言设置
我在表单上调用函数“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 = 芬兰语
我的应用程序工作正常,但此语言设置在屏幕上显示错误的语言。
I call a function "foo.action?request_locale=en" on my form. There is an xwork-validation on that page and I expect to get an validation error in the given language. What I get is a page in Finnish - my browser default language - and I expected one in English.
How it is possible to change the used language on a jsp page (that's where the request_locale comes from) so that the called action from my form will show up with that selected language and not the browser default one?
Some specs:
struts.xml has a line
because my actions are at fi.foo.action directory and i18n resources at fi/foo/package_en.properties and such files.
Validators are at barAction-foo-validation.xml kind of files at fi.foo.action folder.
fi = Finnish
My application works otherwise fine but this language setting is giving wrong language on screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来好像没有为您的操作的拦截器堆栈配置
i18n
拦截器。i18n
拦截器在defaultStack
中第四个定义。确保您的操作没有覆盖堆栈。如果它看起来已配置,请尝试在I18nInterceptor
的intercept
方法中设置断点以确认它正在被调用。否则,你所拥有的应该有效。It sounds like the
i18n
interceptor is not configured for your action's interceptor stack. Thei18n
interceptor is defined fourth in thedefaultStack
. Make sure you are not overriding the stack for your action. If it appears to be configured, then try setting a breakpoint in theintercept
method of theI18nInterceptor
to confirm that it is being invoked. Otherwise, what you have should work.