Lohit
Lohit

Reputation: 891

Struts2 csrf token in velocity template

How to use Struts 2 CSRF token interceptor in Velocity template.

Below is standard JSP example with struts tag

<s:form action="UpdateUser">
<s:textfield name="name" label="User Name">
</s:textfield>
<s:textfield name="address" label="Address">
</s:textfield>
<s:submit name="submit" value="Update">
</s:submit>
<%-- add token to JSP to be used by Token interceptor --%>
<s:token />
</s:form>

Same I want to achieve using Velocity template and want to know how to get token value in Velocity.

Upvotes: 0

Views: 202

Answers (1)

Roman C
Roman C

Reputation: 1

What do you want to know about Velocity, is already integrated in Struts 2. You might want to use tags in velocity type results. You can learn more about it reading Velocity Tags.

Velocity tags are extensions of the generic Struts Tags provided by the framework. You can get jump right in just by knowing the structure in which the tags can be accessed: #s<tag> (...), where tag is any of the Struts Tags supported by the framework.

For using token interceptor for CSRF you should read this answer.

Upvotes: 0

Related Questions