RESTeasy 和返回到带有模型的 JSP 页面 [英] RESTeasy and Returning to a JSP page with a model

查看:28
本文介绍了RESTeasy 和返回到带有模型的 JSP 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种不使用 spring 的简单方法让 RESTeasy 返回带有模型的 jsp 或 html 页面?我想做一些类似于 spring ModelAndView 的事情,我有一个请求说/contacts/loomer 并让它返回一个 jsp 模板中的模拟对象.我看到的所有示例都是针对 JSON/XML 的.我知道在泽西岛你可以使用 viewable,但我只需要使用 RESTeasy 的东西.

Is there an easy, not using spring, way to have RESTeasy return a jsp or html page with a model? I want to do something similar to the spring ModelAndView where I have a request to say /contacts/loomer and have it return a mocked up object in a jsp template. All of the examples I see are for JSON/XML. I know in Jersey you can use the viewable, but I need to use only RESTeasy stuff.

谢谢!

我想要这样的东西(但没有弹簧模型和视图):

I want something like this (but without the spring modelandview):

   @POST
   @PUT
   @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
   @Produces(MediaType.TEXT_HTML)
   public ModelAndView saveContactForm(@Form Contact contact)
         throws URISyntaxException
   {
      service.save(contact);
      return viewAll();
   }

推荐答案

好的,我为任何感兴趣的人解决了这个问题.一旦我找到了一个例子,这实际上是相当微不足道的.

Okay, I figured it out for anyone who is interested. It was actually fairly trivial once I found an example.

@GET
@Path("{eventid}")
@Produces("text/html")
public void getEvent(@Context HttpServletResponse response,
        @Context HttpServletRequest request,
        @PathParam("eventid") Long eventid) throws ServletException,
        IOException {

    EventDao eventdao = DaoFactory.getEventDao();
    Event event = eventdao.find(eventid);

    request.setAttribute("event", event);
    request.getRequestDispatcher("eventView.jsp").forward(request, response);

    }

这篇关于RESTeasy 和返回到带有模型的 JSP 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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