wmhello.java

来自「java servlet编程源码」· Java 代码 · 共 29 行

JAVA
29
字号
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.webmacro.*;
import org.webmacro.servlet.*;

public class WMHello extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
    FastWriter out = new FastWriter(res.getOutputStream(),
                                    res.getCharacterEncoding());

    try {
      WebMacro wm = new WM(); // optionally WM("/path/to/config/file")
      Context c = wm.getWebContext(req, res);
      c.put("date", new Date());
      Template tmpl = wm.getTemplate("hello.wm");
      tmpl.write(out, c);
      out.flush();
    }
    catch (WebMacroException e) {
      throw new ServletException(e);
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?