3
如何从Java过滤器获取请求URL?
我正在尝试编写一个可以检索请求URL的过滤器,但是我不确定该怎么做。 这是我到目前为止的内容: import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import java.io.IOException; public class MyFilter implements Filter { public void init(FilterConfig config) throws ServletException { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { chain.doFilter(request, response); String url = ((HttpServletRequest) request).getPathTranslated(); System.out.println("Url: " + url); } public void destroy() { …