Java ee中的MVC模式以及从spring向Java ee 7的迁移



我以以下方式使用spring MVC:

@Controller
class MyControllerClass {
      @RequestMapping...
      method(){
         ServiceCall()...
      //put something to modelAndView object here and redirect to jsp page.
      return "home"; // this will redirect data to home.jsp
      }
}
@Service
class MyServiceClass{
      @Transactional
      SomeServiceMethod(){ 
        DaoMethod(); 
      }
}

@Repository
class MyDaoClass{
   DaoMethdon(){...}
}
/view/myjsps.jsp  path to view directory set in spring.xml

问题:

任何人都可以向我解释(最好是实际的真实世界的代码示例),我有什么替代方案,上面提到的MVC模式,在Java EE 6/7。ie。控制器,服务,dao,视图层。

此外,如何重定向页面,(我相信普通的requestDispatcher是一种旧的做事方式,必须有一些自动化的方式。modelAndView也是一样。

我已经谷歌了很多,但我找到的都是spring mvc examples

Java EE没有'标准' MVC包。如果您直接使用Java EE,您将直接处理HttpServletRequests、PortletRequests等。在普通Java EE中把对象放在"模型"中基本上是HttpServletRequest.setAttribute()或HttpSession.setAttribute()(如果@SessionAttributes)

最新更新