ServetContext获取方法
一、ServetContext获取方法
在filter 中获取 (过滤器)
LoginFilterFilter{init(FilterConfigfilterConfig)ServletException{filterConfig.getServletContext()}doFilter(ServletRequestservletRequest,ServletResponseservletResponse,FilterChainfilterChain)IOException,ServletException{filterChain.doFilter(servletRequest,servletResponse);}destroy(){}}
在servlet中获取
this.getServetContext()
通过ServletRequest获取
request.getSession().getServletContext()
二.ContextPath 、ServletContextName设置
ContextPath 是指我们在Idea在部署项目时制定的指定
ServletContextName在web.xml中设置
<display-name>haiven-crm</display-name>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。