Struts 中重定向到移动页面
我有一个现有的 Web 应用程序,它使用 Struts 进行转发操作...
我正在尝试创建这个现有 Web 应用程序的移动版本(主要是 UI 设计会有所不同)。
现在这个应用程序正在使用 Struts 2 进行转发操作。
我的问题是我可以扩展这个 Struts XML 以基于桌面/移动设备进行重定向吗? 例如,假设我有desktop.jsp 和mobile.jsp...现在我在服务器级别检测用户来自哪里,并在会话中包含该信息...我可以更新我的stuts-config XML 以便唯一的事情我需要根据用户来自的位置更改“转发”JSP URL 吗? 我没有看到 Action 发生任何变化...只有 JSP 的转发 URL。
请注意,这个问题不是关于“如何检测”,而是更多关于我们检测到浏览器并从服务器获取该信息后应采取什么方法。
谢谢。
I have an existing web app which uses Struts for the forward-action...
I am trying to create a mobile version (mainly the UI design will be different) of this existing web app.
Now this app is using Struts 2 for the forward-action thing..
My question is can I extend this Struts XML to redirect based on desktop/mobile..
e.g. Let's say I have desktop.jsp and mobile.jsp...Now I detect where the user is coming from at a server level and have that info in the session..Can I update my stuts-config XML such that the only thing I need to change would be the "forward" JSP URL based on where the user is coming from?
I am looking at no change to the Action...only the forward URL for the JSP.
Please note that this question is not about "how to detect", but more about what approach to take once we have detected the browser and have that info from the server..
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更好的选择始终是添加
Filter
这里 。剩下如何检测你就知道了。跟踪所有请求检查标头以查明其是否来自移动设备?并根据它服务请求。
Better option is always to add a
Filter
here . and rest how to detect you know it.Track all the request check for the header to find out if its coming from mobile ? and serve request according to it.
您可以将请求转发到另一个操作,该操作将处理要加载的移动特定数据,并且可能会产生不同的结果。一个结果指向desktop.jsp,另一个指向mobile.jsp。
示例:
公共字符串执行(){
if(isMobile())
返回“移动”;
否则返回“桌面”;
}
you can forward the request to another action which will handle the mobile specific data to load and maybe to have different results. One result pointing to desktop.jsp other pointing to the mobile.jsp.
sample:
public String execute(){
if(isMobile())
return "mobile";
else return "desktop";
}