i pass a lot of time trying to solve very simple problem render à string or(List) from controller to view using playframework java and Twirl, my code here
in my controller
public Result list(){
//List<String> todo = Arrays.asList("sup1","sup2","sup3");
String nana = "coco";
return ok(index.render(nana));
}
in my view
@(message: String)
@(nana:String)
@main("Welcome to Play") {
@play20.welcome(message, style = "Java")
<h1>@nana</h1>
}
so there are the some configuration for Twirl or automatically ? anyone help me to render data to view and thanks
What is the error you're seeing? What are the full blocks of code, with all imports?
The syntax seems to be all wrong:
@(...)
line at the top. If you want to pass in two values, you should write @(message: String, nana: String)
at the top of your template. And then you need to pass values for both in when you call index.render(message, nana)
. @main
refers to, since imports aren't listed, but you should try getting it to work first without that block. Render a plain string, then add in some variables, then maybe try for a fancy callback like @main
.