我找不到任何解決方案使用Thymeleaf從URL獲取屬性。 例如,對於URL:Thymeleaf:如何獲取URL屬性值
somesite.com/login?error=true
我需要得到 「錯誤」 的屬性值。 另外我使用SpringMVC,如果它可能會有所幫助。
我找不到任何解決方案使用Thymeleaf從URL獲取屬性。 例如,對於URL:Thymeleaf:如何獲取URL屬性值
somesite.com/login?error=true
我需要得到 「錯誤」 的屬性值。 另外我使用SpringMVC,如果它可能會有所幫助。
經過一番調查,我發現它實際上是Spring EL問題。與空檢查非常完整的答案是:
<div
id="errors"
th:if="${(param.error != null) and (param.error[0] == 'true')}">
Input is incorrect
</div>
在thymeleaf訪問請求參數的另一種方法是使用#httpServletRequest
實用對象,給予javax.servlet.http.HttpServletRequest
對象的直接訪問。
使用示例與空檢查的樣子,
這是相同的java做request.getParameter("error");
。