Jersey Viewable中的JSP 2.2 EL it关键字-在哪里记录? [英] JSP 2.2 EL it keyword in Jersey Viewable - where is it documented?

查看:178
本文介绍了Jersey Viewable中的JSP 2.2 EL it关键字-在哪里记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现,如果我有一个Viewable(球衣)将模型传递给JSP,则访问模型的方法是在地图键前面加上it

I've found out that if I have a Viewable (jersey) passing a model to a JSP, then the way to access it is by prefixing the map key with it

例如

index.jsp

<html>
<body>
<h2>Hello World ${it.foo}!</h2>
</body>
</html>

JAX-RS资源方法:

The JAX-RS resource method:

@GET
@Path("index")
public Viewable index(@Context HttpServletRequest request) {
    System.out.println("/INDEX called");
  HashMap<String, String> model = new HashMap<String, String>();
  model.put("foo","bar");
  return new Viewable("/index.jsp", model);
}

我基于以下资源: http://blog.usul.org/using-jsp-in-a-jersey-jax-rs-restful-application/

但是我想知道,it是什么,它是从哪里来的,它特定于泽西岛吗?如果是,则在哪里记录下来(由于Google倾向于将其从搜索中删除,因此很难搜索"it",这不是双关语)

but I was wondering, what is it and where does it come from, is it specific to Jersey? if so where is it documented (it's hard to search for "it" as google tends to removes it from the search, no pun intended)

在Java EE文档中找不到任何提及.

Could not find any mention of it in the Java EE documentation.

推荐答案

本文档的第17.4节中.它指出:

Jersey将模型实例分配给名为"it"的属性.所以 在隐式示例的情况下,可以引用foo 来自JSP模板的Foo资源上的属性,如下所示:

Jersey will assign the model instance to the attribute named "it". So in the case of the implicit example it is possible to referece the foo property on the Foo resource from the JSP template as follows:

<h1>${it.foo}</h1>

所以it只是Jersey特定的模型属性.由于它是模型属性,因此在呈现视图之前的某个时刻,它会添加到请求属性中.然后可以使用EL访问器${}对其进行访问.如果将其命名为jerseyGuy,则将其作为${jerseyGuy}进行访问.

So it is just a Jersey specific model attribute. Since it's a model attribute, at some point before the view gets rendered, it gets added to request attributes. It can then be accessed with the EL accessor ${}. If it was named jerseyGuy, you would access it as ${jerseyGuy}.

EL使用

EL, which resolves ${...} expressions, uses PageContext#findAttribute() to resolve the attribute name to some attribute in the page, request, session, or application context.

这篇关于Jersey Viewable中的JSP 2.2 EL it关键字-在哪里记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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