Spring 3中使用url参数更改用户的语言,然后删除url参数
我的 Spring 3 application-context.xml 配置中有以下内容,以便用户可以通过任何网页上的下拉菜单更改其语言,
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language"/>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
我可以让该下拉菜单转到类似 /change_language?language=ro 的内容
。然后,该控制器将重定向到 referer
标头中的 url。或者我可以让 javascript 处理这个问题,然后执行 window.location = window.location
?我如何让 javascript 简单地重新加载?
处理用户更改语言并且当前页面的 URL 中没有该语言参数的最佳机制是什么?
I have the following in my Spring 3 application-context.xml configuration so that users can change their language with a dropdown menu on any webpage
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language"/>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
I could have that drop-down menu go to to something like /change_language?language=ro
. That controller would then redirect to the url in the referer
header. Or I could have javascript deal with this and then do a window.location = window.location
? How would I have javascript simply do a reload?
What's the best mechanism for dealing with user's changing their language and not having that language parameter in the URL of the current page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论