我有這樣的 JSP:
<form action="study.show" method="POST>
<input type="hidden" name="arg0" value="${param.arg0}" />
<input type="hidden" name="arg" value="${param.arg}" />
...
URL 有時在 url 中有 arg0 和 arg,有時沒有。因此,如果有 arg0 和 arg,它會發出類似這樣的 POST 請求:
.../study.show?arg0=123abc&arg=arg
但是,如果它不存在,它仍然使用引數發送它:
.../study.show?arg0=&arg=
如何僅在引數存在時附加引數,如下所示:
.../study.show
uj5u.com熱心網友回復:
經過幾個小時的研究,我發現我可以做到這一點:
<c:if test="${not empty param.arg0}">
<input type="hidden" name="arg0" value="${param.arg0}" />
</c:if>
<c:if test="${not empty param.arg}">
<input type="hidden" name="arg" value="${param.arg}" />
</c:if>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/343565.html
標籤:jsp
上一篇:【selenium-python】顯式等待和隱式等待的使用和區別
下一篇:如何使用復數/單數字串替換文本
