【问题标题】:UI is not loading properly (Struts 1 to Struts 2)UI 没有正确加载(Struts 1 到 Struts 2)
【发布时间】:2021-03-11 23:19:09
【问题描述】:

我正在将应用程序从 Struts 1 迁移到 Struts 2,当我在 JSP 文件中将 form 标记更改为 s:form 时,样式和对齐方式加载错误,但是当我离开 form 标记时,页面加载正确。

我添加了taglib!DOCTYPE html PUBLIC

你知道为什么会这样吗?

【问题讨论】:

  • 请参阅How to Ask 页面。这里没有可以用来提供帮助的信息。 听起来您好像不知道 S2 主题。如果不了解 S2 的功能,就无法将 JSP 页面从 S1 直接翻译到 S2。

标签: jsp templates struts2 themes struts-1


【解决方案1】:

Struts2 使用themes and templates 作为标签。

您可以学习here,了解使用 Struts UI 标签时会生成哪些 HTML 内容。

默认情况下,Struts2 使用 xhtml 主题来生成表单字段的 html 内容,例如 textfield 标签。这个主题使用带有输入元素的布局。这会破坏您的设计,因为这些元素放置在标签之外。如果您想使用而不是输入字段,则可以选择css_xhtml theme。如果你想省略生成或者你可以使用简单的主题。例如

<s:form theme="simple">
 <div>
   <s:textfield name="myfield" />
 </div>
</s:form>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多