zoukankan      html  css  js  c++  java
  • java直接跳转页面

    public static String genForwardHtml(String url, Map<String, String> parameters, String charset) {
            StringBuffer returnHtml = new StringBuffer("");
            if (!"".equals(url)) {
                returnHtml.append("<html>");
                String head = "<head><meta http-equiv="Content-Type" content="text/html; charset=" + charset
                        + "" pageEncoding="" + charset + "" />";
                returnHtml.append(head);
                returnHtml.append("<title>loading</title>");
                returnHtml.append("<style type="text/css">");
                returnHtml.append(
                        "body{margin:200px auto;font-family: "宋体", Arial;font-size: 12px;color: #369;text-align: center;}");
                returnHtml.append("#1{height:auto; 78px; margin:0 auto;}");
                returnHtml.append("#2{height:auto; 153px; margin:0 auto;}");
                returnHtml.append("vertical-align: bottom;}");
                returnHtml.append("</style>");
                returnHtml.append("</head>");
                returnHtml.append("<body>");
                returnHtml.append("<div id="3">交易处理中...</div>");
                returnHtml.append("<form name="forwardForm" action="").append(url).append("" method="POST">");
                System.out.println("WebUtils genForwardHtml::url=" + url);
                Iterator keyIterator = parameters.keySet().iterator();
                while (keyIterator.hasNext()) {
                    Object key = keyIterator.next();
                    returnHtml.append("  <input type="hidden" name="").append(key.toString()).append("" value="")
                            .append((String) parameters.get(key)).append(""/>");
                    System.out.println("WebUtils genForwardHtml::" + key.toString() + "=" + parameters.get(key));
                }
                returnHtml.append("</form>");
                returnHtml.append("<SCRIPT LANGUAGE="Javascript">");
                returnHtml.append("    document.forwardForm.submit();");
                returnHtml.append("</SCRIPT>");
                returnHtml.append("</body>");
                returnHtml.append("</html>");
            }
            return returnHtml.toString();
        }

    调用方式

    String result = WebUtils.genForwardHtml(url, paramMap, "utf-8");
    OutputStream out = response.getOutputStream();
    out.write(result.getBytes("utf-8"));
    out.flush();
  • 相关阅读:
    nginx负载均衡实现
    shiro 退出 清除缓存
    从零到实现Shiro中Authorization和Authentication的缓存
    Mysql 语句
    N! java
    大数java(pow)
    HDU_1548
    Mike and strings 798B
    Array Division 808D
    poj_1979(dfs)
  • 原文地址:https://www.cnblogs.com/shihaiming/p/8458635.html
Copyright © 2011-2022 走看看