【问题标题】:Adding variable in HTML tag in Servlet在 Servlet 的 HTML 标签中添加变量
【发布时间】:2012-03-22 06:36:19
【问题描述】:
            String id = (String) request.getParameter("pid");
            String link1 = "http://www2.comp.cityu.edu.hk:8080/servlet/HCPconversationupperframe?pid=" + id;
            String link2 = "http://www2.comp.cityu.edu.hk:8080/servlet/HCPconversationlowerframe?pid=" + id;

            out.println("<frameset rows=\"75%,25%\">");
            out.println("<frame src=\"http://www2.comp.cityu.edu.hk:8080/servlet/HCPconversationupperframe?pid=id\" scrolling=\"auto\" >");
            out.println("<frame src=link2 scrolling=\"auto\" >");

我想让我的链接像这样http://www2.comp.cityu.edu.hk:8080/servlet/HCPconversationupperframe?pid=123 然后调用框架集来调用两个 servlet,但是我无法在 HTML 标记内的链接中添加变量,我该怎么做。

【问题讨论】:

  • 我自己弄的,现在找到了,谢谢大家

标签: java html servlets


【解决方案1】:

首先,您可以将打印标签中的变量连接起来。

但是你真的应该使用 JSP(或其他模板引擎)来输出 HTML。在 servlet 中编写 HTML 确实很难管理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-11
    • 2014-12-19
    • 1970-01-01
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 2021-05-14
    相关资源
    最近更新 更多