简体   繁体   English

JSP 2.2 EL它在Jersey Viewable中的关键字 - 它在哪里记录?

[英]JSP 2.2 EL it keyword in Jersey Viewable - where is it documented?

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 我发现如果我有一个Viewable (jersey)将模型传递给JSP,那么访问它的方法是在地图键前加上it

eg 例如

index.jsp 的index.jsp

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

The JAX-RS resource method: JAX-RS资源方法:

@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);
}

I was basing on this resource: http://blog.usul.org/using-jsp-in-a-jersey-jax-rs-restful-application/ 我基于这个资源: http//blog.usul.org/using-jsp-in-a-jersey-jax-rs-restful-application/

but I was wondering, what is it and where does it come from, is it specific to Jersey? 但我想知道, itit以及它来自哪里,它是否特定于泽西岛? 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) 如果是这样,它在哪里记录(很难搜索“它”,因为谷歌倾向于从搜索中删除它,没有双关语意图)

Could not find any mention of it in the Java EE documentation. 在Java EE文档中找不到任何提及它的内容。

In sections 17.4 of this documentation . 本文档的第17.4节中。 It states: 它指出:

Jersey will assign the model instance to the attribute named "it". Jersey会将模型实例分配给名为“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: 因此,在隐式示例的情况下,可以从JSP模板中引用Foo资源上的foo属性,如下所示:

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

So it is just a Jersey specific model attribute. 所以it只是泽西岛特定的模型属性。 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 ${} . 然后可以使用EL访问器${}访问它。 If it was named jerseyGuy , you would access it as ${jerseyGuy} . 如果它被命名为jerseyGuy ,您将以${jerseyGuy}身份访问它。

EL, which resolves ${...} expressions, uses PageContext#findAttribute() to resolve the attribute name to some attribute in the page, request, session, or application context. 解析${...}表达式的EL使用PageContext#findAttribute()将属性名称解析为页面,请求,会话或应用程序上下文中的某个属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM