Jin Kim
Jin Kim

Reputation: 17722

Use thymeleaf to populate form action

In Thymeleaf, I can output into a input's value using

<input th:value=${message} />

But I don't know how to output into the form action attribute.

Anyone ideas for the Thymeleaf HTML side?

Sample Java Spring-MVC controller code

@Controller
public class SampleController 
    @RequestMapping("/")
    public String home(Model model) {
        model.addAttribute("message", "Hello World!");
    }
}

Upvotes: 0

Views: 1483

Answers (1)

riddle_me_this
riddle_me_this

Reputation: 9125

Use th:action

For example, if you wanted to use the message attribute as a parameter, you can do:

th:action="@{/someUri/foo(message=${message})}"

Upvotes: 4

Related Questions