-->

How to emulate nested:root from Struts 1 in Struts

2020-02-15 06:26发布

问题:

I am working on converting a Struts1 app to Struts2. I have a jsp that has several JSP included. This included JSPs all have the nested:root tag on it.

I have found little to nothing on this particular tag except that is similar to html:root, so I've added the include statement in my main JSP and I added the html:form to the sub JSPs but it didn't work.

I had initially just addeds:form to the sub JSPs and the code in the sub jsp was passed along but none of the tags existing in the sub JSP were processed.

回答1:

All nested tags and all Struts1 tags should be removed/replaced with equivalent Struts2 tags.

Nested tags not needed in Struts2 because it's powered with OGNL. Using OGNL expressions and <s:include> allows to replace nested tags.

If it's not enough to render content with s:include you can use <s:action> but it's heavy and it recreates a valueStack when this tag executes, so it's rarely used, but custom tags or custom components that include Fremarker or Velocity templates can significantly change the rendering time and allows customization.