我有一个名为import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class LdapBaseDN {
public static void main(String[] args) {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "none");
env.put(Context.PROVIDER_URL, "ldaps://MyServerIP:636");
env.put(Context.SECURITY_PROTOCOL, "ssl");
env.put(Context.REFERRAL, "follow");
env.put("java.naming.ldap.factory.socket", MySSLSocketFactory.class.getName()); //MySSLSocketFactory does not get called on Linux
try {
DirContext ldapContext = new InitialDirContext(env);
System.out.println("Connected successfully ");
} catch (Exception e) {
e.printStackTrace(); //SSLHandshake fails because Cert is not trusted on Linux
}
}
}
的端点,该端点获取数据并应返回包含已填充数据的页面。此应用程序不只表示http服务器
和模板ejs视图
/watch
节点js中是否有任何等效项
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<div class="container">
<div>Data</p>
<ul>
<% arr.forEach(function(elem) { %>
<li><%= elem %></li>
<% }); %>
</ul>
</div>
</body>
</html>
这是服务器代码中的摘录
res.render('index', {
arr: data,
});
答案 0 :(得分:1)
您只需要发送<hostname>$HOST</hostname>
创建的字符串。考虑一下EJS显示的准系统示例:EJS#Get Started,并将其与节点为以下目的提供an example的准系统HTTP服务器结合:
ejs.render()
我得到的网络响应是:
const http = require("http");
const ejs = require("ejs");
const template = "<div><%= people.join(',');%></div>";
const people = ["bob", "sue", "steve"];
const server = http.createServer((req, res) => {
res.end(ejs.render(template, {people}));
});
server.listen(8081, () => {
console.log("Listening on 8081");
});