我找不到任何解决方案使用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");
。