我正在使用ServletRequestListener进行实验。我运行程序时得到以下输出。一些请求在初始化之前被销毁。那是为什么?
New request arrived to server :/projeDB/
Request destroyed : /projeDB/javax.faces.resource/primefaces.css.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
Request destroyed : /projeDB/javax.faces.resource/jquery/jquery.js.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
Request destroyed : /projeDB/javax.faces.resource/primefaces.js.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
New request arrived to server :/projeDB/javax.faces.resource/jquery/jquery.js.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
Request destroyed : /projeDB/javax.faces.resource/jquery/jquery-plugins.js.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
Request destroyed : /projeDB/javax.faces.resource/theme.css.xhtml
New request arrived to server :/projeDB/javax.faces.resource/primefaces.js.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
New request arrived to server :/projeDB/javax.faces.resource/jquery/jquery-plugins.js.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
New request arrived to server :/projeDB/javax.faces.resource/primefaces.css.xhtml;jsessionid=2CDF29CD90D3EB1143D06AACAF7BA387
New request arrived to server :/projeDB/javax.faces.resource/theme.css.xhtml
Request destroyed : /projeDB/javax.faces.resource/images/ui-icons_38667f_256x240.png.xhtml
New request arrived to server :/projeDB/javax.faces.resource/images/ui-icons_38667f_256x240.png.xhtml
我的ServletRequestListener:
public class RequestListener implements ServletRequestListener {
@Override
public void requestDestroyed(ServletRequestEvent sre) {
System.out.println("New request arrived to server :" + ((HttpServletRequest) sre.getServletRequest()).getRequestURI()) ;
}
@Override
public void requestInitialized(ServletRequestEvent sre) {
System.out.println("Request destroyed : " + ((HttpServletRequest) sre.getServletRequest()).getRequestURI());
}
}
答案 0 :(得分:2)
您是否在方法中切换了打印语句?您打印请求已在requestInitialized()
方法中销毁,反之亦然。