如何在JspTags中访问请求?
我想在扩展的JSP标签内调用,有什么办法可以做到这一点吗?request.getContextPath()SimpleTagSupport
我想在扩展的JSP标签内调用,有什么办法可以做到这一点吗?request.getContextPath()SimpleTagSupport
首先通过继承的 SimpleTagSupport#getJspContext() 获取 PageContext,然后通过 PageContext#getRequest() 获取 HttpServletRequest。
PageContext pageContext = (PageContext) getJspContext();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();