简体   繁体   English

在jsp页面中重新运行测试而无需重新加载页面

[英]Rerunning test in jsp page without reloading page

Is it possible to rerun a <c:choose> block of code as shown bellow without reloading the JSP page? 是否可以在不重新加载JSP页面的情况下重新运行<c:choose>代码块,如下所示?

<c:choose>
    <c:when test="${salary <= 0}">
       Salary is very low to survive.
    </c:when>
    <c:when test="${salary > 1000}">
        Salary is very good.
    </c:when>
    <c:otherwise>
        No comment sir...
    </c:otherwise>
</c:choose>

This would need to be done in the case that the value of salary changed and a different resut needs to be shown. 如果薪水的价值已更改并且需要显示不同的结果,则需要这样做。

You cannot rerun the c:choose block without reloading the JSP. 您必须重新加载JSP才能重新运行c:choose块。 The JSP is processed on the server side and then sent to the client. JSP在服务器端处理,然后发送到客户端。 The client only gets the rendered result of the c:choose , not the JSP itself. 客户端仅获得c:choose的呈现结果,而不是JSP本身。

When you use JavaScript to update the value, then either repeat the logic in the JavaScript based on the value of salary or request the label via an XMLHttpRequest. 当您使用JavaScript更新值时,请根据salary的值重复JavaScript中的逻辑,或者通过XMLHttpRequest请求标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM