Struts 1 or Struts 2 . Which one is advisable for web application development?

依然范特西╮ 提交于 2019-12-12 18:23:52

问题


I am little bit confused to choose Struts 1 or Struts 2 for my new web application development assignment. Could any one suggest me which framework should I use for development from architecture point of view? What are the points I should take care of to choose the struts version before I go for development of the application? Any help will be appreciated.


回答1:


Hi I prefer struts 2 because,

Struts 1.x

  1. In struts 1.x front controller is ActionServlet
  2. In struts 1.x we have RequestProcessor class
  3. In struts 1.x we have multiple tag libraries like html, logic, bean..etc
  4. In struts 1.x the configuration fine name can be [any name].xml and we used to place in web-inf folder
  5. In struts 1.x we have form beans and Action classes separately
  6. In struts 1.x an Action class is a single ton class, so Action class object is not a thread safe, as a programmer we need to make it as thread safe by applying synchronization
  7. In struts 1.x we have only jsp as a view technology

Struts 2.X

  1. In 2.x front controller is FilterDispatcher
  2. In 2.x we have Interceptors instead RequestProcessor
  3. In 2.x we do not have multiple libraries, instead we have single library which includes all tags
  4. In 2.x the configuration file must be struts.xml only and this must be in classes folder
  5. In 2.x form bean, Action classes are combinedly given as Action class only, of course we can take separately if we want
  6. In 2.x an Action class object will be created for each request, so it is by default thread safe, so we no need to take care about safety issues here
  7. In 2.x we have support of multiple view technologies like velocity, Freemarker, jasper reports, jsp.



回答2:


Since you have mentioned that it is going to be a new web-application,Just go with Struts2.Struts1 has already in EOL which means there will be no loner support for the Struts1.

Also Struts2 is a new and very flexible framework and will provide you a lot more control.Here are

  1. Choose latest version of Struts2 to start work with (2.3.15.1)
  2. If you are planning to write your service layer in Spring, you can use Struts2-spring plugin to let spring DI manage struts2 component for you.
  3. Since you seems new to Struts2, i suggest to pay special attention to OGNL which is a core building block in struts2 and you will going to use it a lot in your Tags at UI.
  4. Struts2 has a very flexible plug-able architecture which let you to create as well use many plugin which can save your time to build functionality from start.

Hope this might help you.Additionally You can review and look in to other MVC framework also




回答3:


I also prefer going with Struts2 itself rather than Struts1 because Struts1 is old and its EOL has been announced on September 1, 2013 with the message "the Struts 1.x web framework has reached its end of life and is no longer officially supported." [Source:- wikipedia.org]

So it is better to go with Struts2[i have been using version:-2.3.1.1 as I faced some "Dispatcher error"(jar files in the package were not compatible with each other) issue while using 2.3.16 version]

Hope this might help.




回答4:


I've had a similar dilemma as you do, but instead of going with Struts, I've chosen Tapestry after some consideration.

Some of its awesome features are

  • Pages as POJOs
  • Really good dependency injection
  • Scalable
  • Easy to learn with lots of examples
  • much more...


来源:https://stackoverflow.com/questions/18773918/struts-1-or-struts-2-which-one-is-advisable-for-web-application-development

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!