public class RequestDataValues extends Object
Expression object that offers the functionality of Spring MVC's RequestDataValueProcessor for performing last-moment modifications to request data values such as URLs or form contents in order to enable mechanism such as CSRF protection.
Methods in this class correspond to the methods in Spring MVC's org.springframework.web.servlet.support.RequestDataValueProcessor.
Using this expression object is not needed in most scenarios, as its functionality will be automatically applied by th:href, th:src, th:action, th:value, th:method and th:field. But sometimes there is a need to manually apply these behaviours when e.g. creating and using URLs outside attributes such as th:href or th:src.
An example of such scenario would be using an URL as a parameter in a message expression:
msg.knowmore=Click <a href="{0}">here</a> if you want to know more.
And then in template code:
<p th:with="morelink=@{/detail/more}"
th:utext="#{msg.knowmore(${#requestdatavalues.url(morelink)})}">
Constructor and Description |
---|
RequestDataValues(org.thymeleaf.context.ITemplateContext context) |
Modifier and Type | Method and Description |
---|---|
String |
action(String action,
String httpMethod) |
Map<String,String> |
extraHiddenFields() |
String |
formFieldValue(String name,
String value,
String type) |
String |
url(String url) |
Copyright © 2016 The THYMELEAF team. All rights reserved.