我想创建一个页面,在按下时会重定向到几个页面。
为了尝试这样做,我编写了以下代码:
[some code here, TRY CATCH is also included]
LdapContext ctx = new InitialLdapContext(env, null);
ctx.setRequestControls(null);
NamingEnumeration<?> namingEnum2 = ctx.search("[path to the server]", "(objectClass=user)", getSimpleSearchControls());
System.out.println("Test: print emails from whole DIRECOTRY: \n");
while (namingEnum2.hasMore()) {
SearchResult result = (SearchResult) namingEnum2.next();
Attributes attrs = result.getAttributes();
System.out.println(attrs.get("mail"));
/** This line above works fine, but every time there is no email
in User info, it prints "null" in some cases when there is
no email, which is not perfect. But this is just here to see
if everything works and indeed it does.**/
/**User Class accepts a String parameter, checks if it's empty
and all that, does some checking and etc... BUT! attrs.get("mail")
is an Attribute, NOT a String. And I need to somehow "cast" this
attribute to a String, so I can work with it.**/
User user = new User(attrs.get("mail")); //error yet,because the parameter is not a String.
User user = new User(attrs.get("mail").toString());//gives an expeption.
/** And I know that there is a toString() method in Attribute Class,
but it doesn't work, it gives an "java.lang.NullPointerException"
exception when I use it as attrs.get("mail").toString() **/
}
在网络服务器日志中,我看到请求仅发送到&#34; c&#34;。
为什么? 如何创建包含多个重定向的HTML页面?
答案 0 :(得分:1)
您将不可避免地需要使用javascript。
<script>
function redirect(){
windows.open("http://www.example.com/a")
windwos.open("http://www.example.com/b")
windwos.open("http://www.example.com/c")
}
</script>
<body onload="redirect()">
没有测试但应该足够
答案 1 :(得分:0)
我不确定你明白,刷新意味着什么。刷新为0意味着浏览器会立即重定向到提供的地址。只要一个浏览器选项卡只能显示一个网页,您的示例就无法运行。
您需要考虑使用Popups或同样的方式一次向用户显示多个页面。