zoukankan      html  css  js  c++  java
  • Java 后能执行JS(JSF)

     1public static void RunJs(String js) {
     2        FacesContext ctx = FacesContext.getCurrentInstance();
     3        String contentType = "text/html;charset=utf-8";
     4        HttpServletResponse response = (HttpServletResponse) ctx
     5                .getExternalContext().getResponse();
     6        response.setContentType(contentType);
     7        ServletOutputStream out = null;
     8        try {
     9            out = response.getOutputStream();
    10        }
     catch (IOException e) {
    11            // TODO Auto-generated catch block
    12            e.printStackTrace();
    13        }

    14        StringBuffer buf = new StringBuffer();
    15        buf.append("<script type=\"text/javascript\">"+js+"</script>");
    16        try {
    17            out.print(buf.toString());
    18        }
     catch (IOException e) {
    19            // TODO Auto-generated catch block
    20            e.printStackTrace();
    21        }

    22    }
  • 相关阅读:
    Codeforces Round #631 (Div. 2)
    Codeforces Round #500 (Div. 2) [based on EJOI]
    KMP+状态机
    状态机模型
    最短编辑距离
    stringstream读入-最优乘车
    多重背包
    Codeforces:B. New Year and Ascent Sequence
    查找目录下所有文件使用到的宏
    QProcess调用外部程序并带参执行
  • 原文地址:https://www.cnblogs.com/wubiyu/p/1229619.html
Copyright © 2011-2022 走看看