我正在为不同的视图编写很多JSP页面.那些JSP检索请求范围属性,它们具有很长的名称以防止重叠.一个例子是:
request.getAttribute("domain1.subdomain1.subdomain11.subdomain111.attributeName");
Run Code Online (Sandbox Code Playgroud)
EL中的等价物是:
${requestScope['domain1.subdomain1.subdomain11.subdomain111.attributeName']}
Run Code Online (Sandbox Code Playgroud)
有时,我的EL表达式很长(例如,当我使用3个不同的JavaBeans来创建HTML标记或调用javascript函数时).
我的问题是我找到的解决方案是否是一个很好的编程解决方案.鉴于每个视图都有自己的页面范围,在我的JSP开头,我想放
<c:set var="attributeName" scope="page" value="${requestScope['domain1.subdomain1.subdomain11.subdomain111.attributeName']}"
Run Code Online (Sandbox Code Playgroud)
然后在我的EL表达式中,我将使用
${pageScope["attributeName"]}
Run Code Online (Sandbox Code Playgroud)
在阅读JSP代码时,这不会引起对属性实际范围的混淆吗?
给定以下 JSON 数组
[
{
"id":1,
"list":[
{"id":1,"type":{"ref":1,"tema":3}},
{"id":2,"type":{"ref":1,"tema":6}}
]
},...
]
Run Code Online (Sandbox Code Playgroud)
使用 jsonPath 表达式,如何获取所有 type.ref==1 的列表元素?在我通过 Google 找到的所有示例中,我找不到具有 2 个级别的过滤器。