我正在编辑不属于我自己的代码,并且需要遵循 RequestDispatcher 的路径。
RequestDispatcher dispatcher = this.getServlet().getServletContext().getRequestDispatcher([url]);
if (dispatcher == null) {
throw new Exception("Unable to find " + [url]);
}
logger.debug("Dispatching request to PDF Writer Servlet " + dispatcher.toString());
dispatcher.forward(request, response);
我怎样才能知道这条路将带我去哪里?
最佳答案
注释掉dispatcher.forward(request,response)行并添加这一行,然后尝试运行servlet。
out.print(this.getServlet().getServletContext().getRealPath([url]));
这将返回调度程序将转发到的路径。
关于java - 追踪dispatcher.forward的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18195584/