struts2:区域设置切换后如何返回用户所在的同一页面?
我正在使用 struts2,并在 struts.xml 中编写了以下用于区域设置切换的代码 -
<action name="switchToEnglish">
<interceptor-ref name="i18n"/>
<interceptor-ref name="basicStack"/>
<result name="input">error.jsp</result>
<result name="success">login.jsp</result>
</action>
<action name="switchToFrench">
<interceptor-ref name="i18n"/>
<interceptor-ref name="basicStack"/>
<result name="input">error.jsp</result>
<result name="success">login.jsp</result>
</action>
现在,在语言切换后出现相同的页面 (login.jsp)。但是,我想返回用户在语言切换之前所在的页面。
提前致谢。
I am using struts2 and in my struts.xml I have written following code for locale switching -
<action name="switchToEnglish">
<interceptor-ref name="i18n"/>
<interceptor-ref name="basicStack"/>
<result name="input">error.jsp</result>
<result name="success">login.jsp</result>
</action>
<action name="switchToFrench">
<interceptor-ref name="i18n"/>
<interceptor-ref name="basicStack"/>
<result name="input">error.jsp</result>
<result name="success">login.jsp</result>
</action>
Now, after language switching same page (login.jsp) appears. But, I want to return on the page where user was before language switching.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有同样的问题。我通过将页面名称传递给操作(通过 GET 或 POST)来解决它,然后我以这种方式在结果中使用它:
不要忘记在操作类中为“currentPage”设置 getter/setter。
这不是最好的方法,但对我的应用程序来说还可以。
I had the same problem. I resolved it by passing the page name to the action(by GET or POST), then I use it in the result this way :
Don't forget to set the getter/setter for "currentPage" in the action Class.
It's not the best way to do it but it was ok for my app.
我还通过向 LocaleAction 发出 AJAX 请求来做到这一点,成功后,只需使用 jQuery 刷新页面,您将停留在区域设置更改之前的同一页面上。
脚本:
和链接:
Also I have made this, with an AJAX request to the LocaleAction, on success, just refresh the page with jQuery and you will stay on the same page where you was before the locale change.
script:
And the links: