开发者

Struts2 ognl execute request method

I'm trying to use OGNL to evaluate if the session is valid, in order to show some information. For that I've the following JSP

[...]
<s:if test="request.isRequestedSessionValid()">
[...] (show user name, etc)
</s:if>

But it d开发者_Python百科oesn't work. I've also tried "#request.isRequestedSessionValid()","%{request.isRequestedSessionValid()}" and "{request.isRequestedSessionValid()}", but I always get an error message target java.lang.NullPointerException: target is null for method isRequestedSessionValid or [OgnlValueStack] Could not find method [#request.isRequestedSessionValid()]. What am I doing wrong?

Thanks!


Okay, now that I've had a chance to look deeper into this I am tossing out my old answer. #request won't work because that is basically the equivalent of the JSP EL expression ${requestScope.requestedSessionIdValid}, but that property isn't a request scope property, its an actual property of the HttpServletRequest.

You can do this easily with JSP EL using:

<c:if test="${pageContext.request.requestedSessionIdValid}">
    ...
</c:if>

I don't know that there is an equally concise way to get at this with OGNL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜