为什么我们使用struts标签而不是旧的HTML标签,它带来了什么区别? [英] Why do we use struts tags and not the old HTML tags , what difference does it bring?

查看:135
本文介绍了为什么我们使用struts标签而不是旧的HTML标签,它带来了什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是struts的新手,并且想要知道为什么我们在以前的html标签上引用struts标签时它们似乎都在做同样的事情,
在html标签上使用struts标签的优点是什么。
like

I am new to struts , and wanna know why do we refer struts tags over previous html tags when they both seem to be doing the same thing , what is the advantage of using struts tags over html tags . like

<s:form action="myAction">
    <s:textfield name="username"></s:textfield>
    <s:textfield name="password"></s:textfield>
    <s:submit name="submit" value="submit"></s:submit>
</s:form>

<form action="myAction" method="post">
    <input type="text" name="username"/>
    <input type="text" name="password"/>
    <input type="submit" name="submit"/>
</form>

我用谷歌搜索了它,但没有得到任何令人满意的答案,提前感谢帮助

I have googled it , but have not got any satisfying answer , help is appreciated in advance

我知道它添加了一些额外的东西,比如标签或其他东西,这对我来说很好,但是我想知道它是否对性能或任何特定于请求对象的任何事情做了什么,其他任何事情只是为了避免程序员的额外打字。

I know it adds some extra things like labels or something , that is fine with me , but what i wanna know if it does anything with the performance or anything specifically to the request object , anything other just avoiding the extra typing for the programmer .

推荐答案

有不同类型的Struts 2标签。

There are different types of Struts 2 tags.

特别是表单标签是有益的,但它们的功能完全取决于所使用的Struts 2主题。 简单主题提供的标准HTML标签几乎没有任何好处。默认的xhtml主题会发出表格行和一些样式。自定义主题实现您想要的任何功能。无论主题如何,底层JSP源都不需要改变。

Form tags in particular are beneficial, but their functionality depends entire on the Struts 2 theme being used. The "simple" theme provides almost no benefit beyond standard HTML tags. The default "xhtml" theme emits form table rows and some styling. Custom themes implement whatever functionality you desire. Regardless of the theme the underlying JSP source never needs to change.

主要优点是:


  • 验证错误消息

  • 表单呈现/样式

  • 框架集成(例如,从操作中自动填充的值)

还有一组Dojo(非常弃用)和jQuery标签在自定义标签中包含了大量的JavaScript功能,这使得简单的动态功能非常简单。

There are also a set of Dojo (very deprecated) and jQuery tags that wrap up a fair amount of JavaScript functionality in custom tags, which makes simple dynamic functionality very simple.

还有非视图标记,例如< s:iterator> 等。它们的一些功能是JSTL的重复(在迭代器标记的情况下,< c:forEach> )。在功能重叠的情况下,使用S2标签没有太多好处。

There are also non-view tags, like <s:iterator> etc. Some of their functionality is a duplicate of JSTL (<c:forEach> in the case of the iterator tag). There aren't a huge number of benefits to using the S2 tags in this case when functionality overlaps.

有些标签没有JSTL模拟,比如 < s:merge> < s:sort> 。 ,该功能是否适用于视图层是一个不同的讨论。有些提供了与Struts 2的其他方面的集成,例如I18N(例如,< s:text> )。有些人了解Struts 2的配置(例如,< s:url> )。

Some tags have no JSTL analog, like <s:merge> or <s:sort>. , Whether or not that's functionality suitable for the view layer is a different discussion. Some provide integration into other aspects of Struts 2, like I18N (e.g., <s:text>). Some understand about Struts 2 configuration (e.g., <s:url>).

任何自定义标记用于简化视图层编程(例如,JSP)。 S2提供了很多标签来帮助解决这个问题。有些是简单和通用的(非UI标签),而UI标签是使用FreeMarker实现的,并且可以大量定制。

The purpose of any custom tag is to simplify view layer programming (e.g., JSP). S2 provides a lot of tags to help with that. Some are simple and generic (non-UI tags), while the UI tags are implemented using FreeMarker and are heavily customizable.

这篇关于为什么我们使用struts标签而不是旧的HTML标签,它带来了什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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