开发者

How to create multiple views of same interface with struts?

开发者 https://www.devze.com 2023-01-28 08:09 出处:网络
Basically,I am开发者_StackOverflow creating a site which will be accessible via Mobile and desktop. So i want to create 2 views.

Basically, I am开发者_StackOverflow creating a site which will be accessible via Mobile and desktop. So i want to create 2 views.

My action code remains same. Everything else is same. Just jsp changes for both. How i can do this via struts 1/2 ?


You can also do this by adding third party jar "deli.jar" and using its Profile, Workspace etc. class to detect the type of mobile from which the url is being requested. In struts you can make the page viewed by Mobile user by making it in xhtml, as follows
<html:html xhtml="true"

But this will only supported for the mobile which have xhtml enabled browser.

Hope this will help you.


You will need to pass in a query parameter or something in the header which will distingush between the 2 requests. For example: http://yoursite.com/render.action?type=mobile.

Finally in your action:

if ("mobile".equals(type)){
  return "mobile";
}else { 
  return ActionSupport.SUCCESS;
}

In your struts have a new result-type

 <result name="success">/WEB-INF/jsp/somethign/web.jsp></result>
 <result name="success">/WEB-INF/jsp/somethign/mobile.jsp></result>
0

精彩评论

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