比较 spring mvc 3 和 struts 2

发布于 2024-10-03 21:23:17 字数 158 浏览 1 评论 0原文

即将启动一个 java EE 项目。(业务需求仍在变化中。) 对于 Web 层,我们研究了各种 Java Web 框架并淘汰了基于组件的框架,例如 JSF、Wicket。现在谈到 spring mvc 3 或 struts 2。 谷歌搜索了一下,发现没什么有用的信息。谁能说说他们的优缺点吗?谢谢。

Just about to start a java EE project.(Biz requirement is under change still.)
For the web tier, we looked at various java web frameworks and eliminated component-based ones such as JSF, Wicket. Now it comes to spring mvc 3 or struts 2.
Googled it and found little useful info. Can anyone talk about their pros and cons? Thanks.

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

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

发布评论

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

评论(3

后来的我们 2024-10-10 21:23:17

我接手了一个 Struts 2 + Guice Web 应用程序,它使用 REST 插件来进行约定优于配置。起初很容易完成,但我遇到了一些难以克服或无法克服的障碍。

其中之一是我需要在 URI 的路径中包含内部点/句点字符,而 Struts 2 + REST 不允许这样做,因为它会将点解释为指示文件扩展名并尝试编组到适当的视图(例如捕获 .xml 和 .json)。

因此,我最终在 Spring 3 中重写了 web 应用程序,并能够解决所有在 Struts 2 中无法处理的问题。我对 Spring 3 感到非常满意,发现它的编码速度与 Struts 2 一样快。尽可能坚持基于注释的配置,并尝试尽可能使用 JSR 版本(330 @Inject 和 303 @Valid 等),这样,如果我决定摆脱 Spring,我就不会坚持使用自定义 Spring注释。

我的投票是Spring 3。

I took over a Struts 2 + Guice web app that used the REST plugin to do convention over configuration. It was very easy to work on at first but I ran into a couple of hurdles that were either difficult or impossible to overcome.

One of these was that I needed to have internal dot/period characters in the path of the URI and Struts 2 + REST did not allow this, as it would interpret the dot to indicate a file extension and try to marshall to the appropriate view (e.g. like catching .xml and .json).

So I ended up rewriting the webapp in Spring 3 and was able to fix all those issues I couldn't handle in Struts 2. I've been much happier with Spring 3 and found it just as fast to code in as Struts 2. I've stuck with annotation based configuration as much as possible and tried to use the JSR versions where ever possible (330 @Inject and 303 @Valid, etc), so that if I decide to get rid of Spring I am not stuck with custom Spring annotations.

My vote is Spring 3.

羞稚 2024-10-10 21:23:17

在另一个 stackoverflow 问题中,您有很多比较 struts 和春天。尽管其中许多人没有明确提及 Spring 3 版,但比较与 2.5 版类似。

正如他们中的许多人所说,我更喜欢春天。当您使用注释时,事情会变得更容易。与 Spring-mvc 相比,我不喜欢 Struts 2 的一个事实是,您必须为要在操作中获取的每个属性添加 getter 和 setter。我认为Spring这样更干净。

In this other stackoverflow question you have a lot of answers comparing struts and Spring. Though many of them don't mention explicitly the version 3 of Spring the comparison would be similar to the version 2.5.

As many of them say, I'd prefer Spring. It makes things easier when you use annotations. One fact I don't like in Struts 2 in comparison with Spring-mvc is that you have to add getters and setters for every property you want to get in the actions. I think Spring is cleaner in this way.

我不在是我 2024-10-10 21:23:17

@贾维
Struts2 中有多种选项可以避免这些 getter 和 setter,其中之一是 id ModelDriven 拦截器

好吧,我投票给 Struts2,因为我已经在它上面工作了很长时间,但这并不意味着 Spring MVC 不好,我也研究过它,它的同样好..

选择权在于您,这取决于您最喜欢 Spring 或 Struts 中的哪个词

@Javi
You have various options in Struts2 to avoid these getter and setter one of them id ModelDriven interceptor

Well my vote is for Struts2 since i am working on it from so long but this does not mean Spring MVC is bad i have worked on it also and its equally good..

Choice is all yours and it depends what word you like most Spring or Struts

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