Struts 有什么好处

发布于 2024-08-02 01:46:37 字数 313 浏览 3 评论 0原文

我最近将 Struts 1.3 添加到 Tomcat 上的应用程序中。 这是我的观察,

  1. MVC。 Servlet/JSP 对我来说做得很好,其中 JSP 是视图,servlet 是控制器。 我认为从 XML 文件获取映射没有任何好处,因为我们的映射是非常静态的。
  2. 行动表格。 我可以看到行动形式的一些好处,但不是很大。
  3. 标签。 我已经使用了 JSTL,并且没有发现使用 Struts 标签有任何优势。

所以我正在考虑删除Struts。 任何人都可以想到我可能错过的任何其他好处吗?

I recently added Struts 1.3 to my application on Tomcat. Here are my observations,

  1. MVC. Servlet/JSP does this fine for me, where JSP is the view and servlet is the controller. I don't see any benefit to get the mapping from an XML file since our mapping is very static.
  2. Action Form. I can see some benefits of action form but not huge.
  3. Tags. I already uses JSTL and don't see any advantage using Struts tags.

So I am thinking about removing Struts. Anyone can think of any other benefits I might have missed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

谜兔 2024-08-09 01:46:37

我个人更喜欢jsp/servlet,但理论上Struts有一些优势。
以下是我所知道的一些优点,您可能已经提到过它们,但我认为如果我在这里列出所有优点会更好。

  1. 基于文件的集中配置。
    Struts 值/映射以 XML 或属性文件表示。 这种松散耦合意味着无需修改或重新编译 Java 代码即可进行许多更改,并且可以通过编辑单个文件来进行批量更改。 这种方法还可以让 Java 和 Web 开发人员专注于他们的特定任务(实现业务逻辑、向客户端呈现某些值等),而无需了解整个系统布局。

  2. 形成 Bean。

  3. Bean 标签。
    Struts 提供了一组自定义 JSP 标记,使您可以轻松输出 JavaBeans 组件的属性。

  4. HTML 标签。
    Struts 提供了一组自定义 JSP 标记来创建与 JavaBeans 组件关联的 HTML 表单。 这个 bean/form 关联有两个有用的目的:

    • 它允许您从 Java 对象获取初始表单字段值。
    • 它可以让您重新显示表单,并且之前输入的部分或全部值保持不变。
  5. 表单字段验证。
    Struts 有一个强大的、可扩展的验证器,可用于统一验证您的表单字段。 此验证可以在服务器上执行(使用 Java),或者同时在服务器和客户端上执行(使用 JavaScript)。

  6. Struts 框架中包含的“管道代码”。
    例如,将 HTTP 请求参数映射到 Java 对象是由 Struts 处理的。 你不必这样做。 这使您可以更多地关注领域问题,而不是构建基础设施。

  7. 良好的文档& 很多书。
    如果您必须离开该项目和/或其他人必须维护它,那么使用众所周知且有据可查的框架将使这项工作变得更加容易。 自制框架无法与之相比。

  8. 广泛的用户测试。
    由于 Struts 在大量 Web 应用程序中使用,因此与您单独编写的任何框架相比,该框架将受到更多人的关注。 通常,但并非总是如此,这意味着您遇到的任何问题都会先被其他人看到(并有望得到解决)。

Personally I myself prefer jsp/servlet but theoretically Struts has some advantages.
Here are some of the advantages i know of, you might have mentioned them already, but i thought it would be better if i list all of them here.

  1. Centralized File-Based Configuration.
    Struts values/mapping are represented in XML or property files. This loose coupling means that many changes can be made without modifying or recompiling Java code, and that wholesale changes can be made by editing a single file. This approach also lets Java and Web developers focus on their specific tasks (implementing business logic, presenting certain values to clients, etc.) without needing to know about the overall system layout.

  2. Form Beans.

  3. Bean Tags.
    Struts provides a set of custom JSP tags that let you easily output the properties of JavaBeans components.

  4. HTML Tags.
    Struts provides a set of custom JSP tags to create HTML forms that are associated with JavaBeans components. This bean/form association serves two useful purposes:

    • It lets you get initial form-field values from Java objects.
    • It lets you redisplay forms with some or all previously entered values intact.
  5. Form Field Validation.
    Struts has a robust, extensible validator that can be used to uniformly validate your form fields. This validation can be performed on the server (in Java), or both on the server and on the client (in JavaScript).

  6. "Plumbing code" contained within the Struts framework.
    Mapping HTTP request parameters to Java objects is handled by Struts, for example. You don't have to do it. This allows you to focus more on the domain problem instead of building infrastructure.

  7. Good documentation & plenty of books.
    If you have to leave the project and/or someone else has to maintain it then using a well known and well documented framework will make that job much easier. A homebrewed framework just can't match that.

  8. Broad user testing.
    Since Struts is used in plenty web-apps the framework will get looked at by many more eyes than anything you could write alone. Usually, but not always, that means any problems you have will have been seen by someone else (and hopefully resolved) first.

昨迟人 2024-08-09 01:46:37

庞大的知识库。
我同意这可能不像以前那样有效,但多年来 Struts 已在许多项目中使用。 从可维护性的角度来看,使用众所周知的框架可以让其他人更轻松地处理您的应用程序,也有助于为未来构建您自己的简历。 目前,大多数开发都在基于组件的空间中(例如 JSFwicket, 挂毯< /a>)或类似 Rails 的空间(如 railsgrails, lift) 但 struts 架构仍然是正在使用且有效。

你没有说你是否在公司环境中开发,对于个人项目来说,也许可维护性问题并不是那么大的问题。

如果您认为 struts 很适合您,您还可以看看 stripes,这是一个类似 struts 的框架基于相同的概念,但在配置方面更简洁,具有更合理的默认值、更少的 xml 和对注释的支持。

Large knowledge base.
I agree that this perhaps isn't as valid as it used to be but Struts has been used in a lot of projects over the years. From a maintainability point of view using a well known framework makes it easier for other people to work on your application and also help build your own resumé for the future. Right now most development is either in the component based space (like JSF, wicket, tapestry) or in the rails-like space (like rails, grails, lift) but the struts arcitechture is still in use and valid.

You didn't say if you develop in a corporate environment or not, for a personal project perhaps the maintainability issue isn't that much of a problem.

If you decide that struts suits you well you could also have a look at stripes, a struts-like framework that's based on the same concepts but is less verbose when it comes to configuration with more sensible defaults, less xml and support for annotations.

若无相欠,怎会相见 2024-08-09 01:46:37

我完全同意您关于 Struts 的观点——我个人认为它的时代已经过去了。

我在 v1 中放弃了 Struts(我相信它与最新版本完全不同),因为表单 bean 只是添加了要编写的样板代码。

从那时起,我开发的大多数应用程序都使用 Spring 作为依赖注入框架,这使得 Spring MVC 成为自然的选择 - 它简单、直接且最小。

I totally agree with your points about Struts - personally I think its time has come and gone.

I went off Struts in v1 (which I believe is nothing like the latest versions) because the form beans where just added boilerplate code to write.

Since then most applications I've worked on are using Spring as the dependency injection framework, which has made Spring MVC the natural choice - it's simple, straight forward and minimal.

挖鼻大婶 2024-08-09 01:46:37

不仅仅适用于 Struts。 但使用框架需要考虑以下几点:

  • 标准化。
  • 适用于您最喜欢的 IDE 的专用 IDE 或插件。
  • 可移植性。 例如,某人可以开发一个 portlet,用于将现有的 struts 应用程序集成到门户服务器中。
  • 国际化。

对我来说最重要的是:

  • 你不必担心struts代码的问题,只需升级即可。
  • 您可以将工作重点放在业务逻辑上。

Not just for Struts. But some points to consider for using a framework:

  • Standarization.
  • Specialized IDE or plugins for your favourite IDE.
  • Portability. For example, someone can develope a portlet for integrate your existing struts application in a portal server.
  • Internationalization.

The most important for me:

  • You dont have to worry about the issues on the struts code, just upgrade.
  • You can focus your work in business logic.
诗化ㄋ丶相逢 2024-08-09 01:46:37

Struts 是开源的——
大社区----
可用书籍数量-----
经过验证的框架----
流行框架-----
自2001年上市----
+----
上面提到的功能…………

但是当你使用struts时,更好的选择是struts2。

Struts is Open Source--
Large Community----
Number of Books available-----
Proven FrameWork----
Popular framework-----
Available since 2001----
+----
the features mentioned above...........

but when u r using struts,the better choice is struts2.

会傲 2024-08-09 01:46:37

我认为您对删除 Struts 的感觉是合理且可以理解的反应。 Struts 似乎对应用程序没有做太多事情。

I think your feeling about removing Struts is a sound and understandable reaction. Struts just doesn't seem to do very much for an application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文