开发者

What technologies are best for my application: Struts with Hibernate or Spring with Hibernate

I have a working knowledge of Struts2 and Spring. I want to develop an application that manages information for multiple companies. I am totally confused about what technologies are best for my application. For instance: Struts2, and Hibernate MVC with Spring. 开发者_开发百科Can somebody help me select appropriate technologies?


Here is a quick breakdown of a J2EE stack you can use:

  1. Use Struts2 for your controller layer

  2. Use Hibernate for your data abstraction layer. Create service interfaces for your DAO. The interfaces will allow you to use some type of RMI for services later if desired, meaning those services can run on different machines than your web app. Have concrete classes implement those interfaces. The classes will contain business logic and validation of data, and will wrap the Hibernate session. The Hibernate session is used to read/write to/from the database. Use Hibernate annotations to expedite the implementation of Hibernate beans.

  3. Use Spring for instantiating your service classes and Struts2 actions. Configure Spring to inject service instances into your Struts2 actions. This is called dependency injection. Reference interfaces, not classes in your Struts2 action's setter methods for the DI.

  4. Use the Struts2 tag library or JSTL in your JSP, which will be your view layer.

  5. Use Maven for your builds and deploys.

  6. Run Apache with mod_jk, and use Tomcat as your servlet container. mod_jk runs w/ the Apache process, and passes requests to the Tomcat servlet container, which lives in the JVM.

  7. If your application requires search capabilities, use SOLR, a REST service built on top of Lucene.

  8. Instead of using Struts2, you could also take a look at Apache Wicket.


I had the same question few days back and following are the links I used to make a decision - I settled for Spring MVC. Also check out Spring ROO if you are starting afresh.

  1. Choosing the right web framework
  2. Comparing web frameworks
  3. What Web Application Framework?

Ultimately choice will be based on your needs - but above links discuss what parameters you should consider before choosing one.

Hope that helps.


Agree with @Simian, and add some comments and reasons.

From a technological perspective, you should use any framework that utilize modern and mature technologies, such as Struts 2, Spring MVC, Hibernate, JSF, and etc.

However, from a business perspective, you should take more emphasis on the business model that your project consist of, and the demand for the framework is easy and rapid to implement, as well as robust and easy to maintain.

Therefore, as you are familiar with Struts 2, and Spring, I recommend:

1, Use Struts 2 as the MVC framework of your project, but use AJAX if required. You can also develop your interceptors to fulfill some common requirements of your project. (Or, if you have time, you can learn Spring MVC as it works well with Spring framework, and has better support of AJAX and RESTful. JSF is not recommended, not because it isn't a superb framework, but it use a set of complete different concepts comparing to Struts 2 and Spring MVC, and it is difficult for an unskilled person to debug )

2, Just use Spring jdbcTemplate as your data layer, use DAO pattern to decouple. (Or , you can learn Hibernate or JPA as your ORM framework, if you have time.)

3, Use Spring IoC to manage your objects and integration with Struts 2 and Hibernate, and manage transactions with Spring's annotations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜