本文介绍了如何在JspTags中访问请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在扩展 SimpleTagSupport 的JSP标记内调用 request.getContextPath(),有什么办法吗?这样做?

I want to call request.getContextPath() inside a JSP tag which extends SimpleTagSupport, is there any way to do it?

推荐答案

首先得到由继承的然后获取 jsp / PageContext.html#getRequest%28%29rel =noreferrer> PageContext#getRequest()

First get the PageContext by the inherited SimpleTagSupport#getJspContext() and then get the HttpServletRequest by PageContext#getRequest().

PageContext pageContext = (PageContext) getJspContext();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

这篇关于如何在JspTags中访问请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 02:59