开发者

Redirect to Mobile pages in Struts

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 up开发者_运维问答date 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.


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.


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"; }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜