如何模拟 <nested:root>从 Struts 1 到 Struts 2? [英] How to emulate <nested:root> from Struts 1 in Struts 2?

查看:19
本文介绍了如何模拟 <nested:root>从 Struts 1 到 Struts 2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Struts 1 应用程序转换为 Struts 2.我有一个包含多个 JSP 的 jsp.这包括的 JSP 都有 <nested:root> 标签.

I am working on converting a Struts 1 app to Struts 2. I have a jsp that has several JSP included. This included JSPs all have the <nested:root> tag on it.

除了类似于 <html:root> 之外,我在这个特定标签上几乎没有发现任何东西,所以我在我的 main 中添加了 include 语句JSP 和我将 <html:form> 添加到子 JSP 中,但它不起作用.

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.

我最初只是将 <s:form> 添加到子 JSP 中,并且子 JSP 中的代码被传递,但子 JSP 中存在的任何标记都没有被处理.p>

I had initially just added <s: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.

推荐答案

所有 nested 标签和所有 Struts1 标签都应该被删除/替换为等效的 Struts2 标签.

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

Struts2 中不需要嵌套标签,因为它由 OGNL 提供支持.使用 OGNL 表达式和 <s:include> 允许替换嵌套标签.

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

如果使用 s:include 渲染内容还不够,您可以使用 <s:action> 但它很重,并且在执行此标记时会重新创建 valueStack,因此很少使用,但自定义包含 Fremarker 或 Velocity 模板的标签或自定义组件可以显着改变渲染时间并允许自定义.

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.

这篇关于如何模拟 &lt;nested:root&gt;从 Struts 1 到 Struts 2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆