jakarta-ee - spring mvc Controller 等效于 javaee Controller

标签 jakarta-ee spring-mvc model-view-controller java-ee-6 java-ee-7

我使用了 Spring 。

纯纯 java-ee 6/7 是否有等效的 Controller 策略? 就像有 Spring Controller 负责处理路径参数、请求参数、返回类型、重定向、重定向到带有 modelAndView 对象的 View 来携带数据?

@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

      }
}

最佳答案

一个想法是使用 JAX-RS 的 Jersey 实现.

Controller 看起来像:

@Path("same_as_the_class_request_mapping")
public class MyControllerClass{

    @Path("pretty_much_same_as_the_method_request_mapping")
    @GET //or whatever you need
    public Viewable roaster(){
        //do whatever
        return new Viewable("home", some_model_object);
    }
}

您可以查看更多信息here和一个很好的教程here .

Jersey 还使您能够与 Spring 集成,从而使人们能够从 Jersey Controller 调用 Spring 服务。查看this了解更多详情

关于jakarta-ee - spring mvc Controller 等效于 javaee Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24360808/

相关文章:

java - Spring MVC、RESTful 服务和 Apache Shiro 策略

model-view-controller - 身份验证模型适合 MVC 框架的什么地方?

java - 具有容器管理事务的单例 EJB 并发

动态 Web 项目的 Java 类路径

java - 帮助使用 Spring 创建图像 servlet

java - AMQP 防止自动消息读取

C++ Qt : QStyledItemDelegate's createEditor is never called, 尽管调用了 paint()

php - 使 PHP 网站面向对象和 MVC 的正确方法是什么?

java - 在 Debian 中设置 Java EE 开发环境

GlassFish 开源版 3.1 上部署 war 时出现 java.lang.AbstractMethodError