(JSP)$ {errorString}是做什么的?以及它如何运作?

时间:2019-03-08 05:41:40

标签: jsp

在一个jsp文件中,我看到了以下代码。

<div class="hud-chat-message" id="message" onclick="copyToInput(this);"> SOME TEXT HERE </div><hr> <div class="hud-chat-message" id="message" onclick="copyToInput(this);"> SOME MORE TEXT HERE </div><hr> <div class="hud-chat-message" id="message" onclick="copyToInput(this);"> EVEN MORE TEXT HERE </div><hr> <input type="text" name="message" class="hud-chat-input" placeholder="Enter your chat message..." maxlength="140">

据我所知,$ {}是JSP EL。我想知道errorString如何工作。我查看了代码,但找不到如何返回该值。 (这是隐式的EL对象吗?) 通过直觉,它看起来像显示错误消息的东西。

<p style="color:red;"> ${errorString} </p>如何工作?它是做什么的?

1 个答案:

答案 0 :(得分:1)

例如,假设您拥有servlet类,并且在重定向到任何message页面后需要显示一些Jsp:即

 request.setAttribute("errorString", "Invalid user ");//we set attribute with some message.

在jsp页面上方的消息中,display使用以下命令:${errorString}

检查this以获得更多详细信息。

相关问题