How to access request in JspTags?

冷暖自知 提交于 2019-12-18 03:09:22

问题


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


回答1:


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();  


来源:https://stackoverflow.com/questions/2098796/how-to-access-request-in-jsptags

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!