如果cookie不存在,我试图显示一个div,当设置cookie时,我不希望div再显示(将隐藏在CSS中)
但我不能让div显示它什么时候没有饼干,有人知道我做错了吗?
import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
public final class Router {
private static final String DEFAULT_GATEWAY = "Default Gateway";
private Router() {
}
public static void main(String[] args) {
if (Desktop.isDesktopSupported()) {
try {
Process process = Runtime.getRuntime().exec("ipconfig");
try (BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.trim().startsWith(DEFAULT_GATEWAY)) {
String ipAddress = line.substring(line.indexOf(":") + 1).trim(),
routerURL = String.format("http://%s", ipAddress);
// opening router setup in browser
Desktop.getDesktop().browse(new URI(routerURL));
}
System.out.println(line);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
答案 0 :(得分:-1)
if (document.cookie.indexOf("mycookie") == 0) {
return false; // cookie is not set
}else{
return true; // cookie is set
}