我目前在我的Java应用程序中使用JxBrowser作为嵌入式浏览器。我创建一个浏览器,如下所示:
public static void main(String[] args) {
Browser browser = new Browser();
BrowserView browserView = new BrowserView(browser);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.add(browserView, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
browser.loadURL("https://developer.microsoft.com/en-us/graph");
frame.addWindowListener(new WindowListener() {
@Override
public void windowClosing(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(browserView, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
browser.getCacheStorage().clearCache();
browser.loadURL("https://developer.microsoft.com/en-us/graph");
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
});
}当第一个URL打开时,我登录并选择不保持登录状态。然后我关闭该窗口,当第二个窗口打开时,我看到我的用户仍在登录。正如您所看到的,在第二次打开URL之前,我也清除了缓存。但是缓存不会被清除。
发布于 2018-11-19 19:43:14
我不确定这个问题是否与缓存有关。你能创建一个简单的样本,可以用来从我这一端复制问题吗?
https://stackoverflow.com/questions/53319908
复制相似问题