java ee中的mvc模式,从spring迁移到java ee 7 [英] mvc pattern in java ee and migrating from spring to java ee 7

查看:216
本文介绍了java ee中的mvc模式,从spring迁移到java ee 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以下列方式使用spring MVC:

I used spring MVC in the following manner:

@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

问题:

任何机构都可以向我解释(最好用实际的真实世界代码示例( s)),对于Java EE 6/7中的上述MVC模式,我有什么替代方案。即。控制器,服务,dao,视图层。

Can any body explain to me (preferably with actual real world code example(s)), that what alternatives do I have, for the above mentioned MVC pattern, in Java EE 6/7. ie. controller, service, dao, view layers.

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

Further more, how to redirect pages, (I believe plain requestDispatcher is an old way of doing things, there got to be some automated ways. Same goes with modelAndView.

I谷歌搜索了很多,但我找到的只是 spring mvc examples

I have googled a lot but all I find is spring mvc examples.

推荐答案

的Java EE没有一个标准 MVC包。如果你去,你会直接与HttpServletRequests,PortletRequests要处理直的Java EE等在普通的Java EE的模型把对象基本上是HttpServletRequest.setAttribute()或者HttpSession.setAttribute()(如果@SessionAttributes)

Java EE doesn't have a 'standard' MVC package. If you go straight Java EE you'll be dealing directly with HttpServletRequests, PortletRequests etc. Putting objects in the 'model' in plain Java EE is basically HttpServletRequest.setAttribute(), or HttpSession.setAttribute() (if @SessionAttributes)

这篇关于java ee中的mvc模式,从spring迁移到java ee 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆