【问题标题】:html tag ID referenced in java code in JSPJSP中java代码中引用的html标签ID
【发布时间】:2015-09-19 17:18:08
【问题描述】:

有没有办法在jsp中引用java代码中html标签的id,例如:

...
<body>
    <h1>Order state</h1>

    <p id="name">Customer name: ${p.customerName}</p><br />

...

<%

        request.setAttribute("customerName", <object>);
%>
...

所以在这个例子中,我想在 java 代码中引用段落的值 ${p.customerName} 来代替

【问题讨论】:

    标签: java html jsp tags


    【解决方案1】:

    由于 ${p.customerName} 是一个 JSTL 变量,默认情况下它设置在页面范围内。所以你可以使用:

    request.setAttribute("customerName", pageContext.getAttribute("customerName"));
    

    【讨论】:

    • 感谢您的建议。它不在jstl中。我调试了它,不幸的是它没有获取该 html 标记的值
    猜你喜欢
    • 1970-01-01
    • 2010-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-24
    相关资源
    最近更新 更多