How to apply a global dynamic result path prefix in Struts 2 so can reskin JSPs?

狂风中的少年 提交于 2019-12-25 04:15:41

问题


I have a website using Struts2 as the MVC framework. I need to re-skin the JSPs. I need to have the old JSPs accessible alongside the new JSPs. So I have added a root folder of /newdesign/ and copied all of the existing JSP folders into it.

So if I login with the name/value pair ?newdesign=true (for example) I'm the initial request then I can:

  1. store this in the user's session and then
  2. dynamically add /newdesign/ as a global prefix to the tag in struts.xml that determines if the new or old JSP is loaded for the related Action.

This way the developer can check if all the old page has been re-skinned into a new page.

How do I do part 2. above? - I have looked at using struts.convention.result.path = /newdesign but this is not dynamic and I cannot change it if the user is to be shown the old or new JSPs.


回答1:


If you know the part 1 then assume you could set the parameter to the action that should redirect to the appropriate action of the other packages that contain the namespace that is corresponding to your parameter newdesign.

The prefix to the action name used in the url specify the namespace used to separate actions in packages.

If you have multiple modules that has the same action names and results but different locations that depends on namespace then you should configure them in different packages that have their own namespaces. There's an example that would let you better understand the namespaces concept.

You could configure as many packages as modules you have with new designs. If there's not too many of them then it could be simply done like in example. But instead of switching to the appropriate namespace depending on parameter you could add that parameter to the namespace pattern used via wildcard mappings.



来源:https://stackoverflow.com/questions/16523683/how-to-apply-a-global-dynamic-result-path-prefix-in-struts-2-so-can-reskin-jsps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!