Reputation: 25
I am using the Java Play Framework and trying to pass array values from controller to view, but I got error. My code is here:
public class Application extends Controller {
public static Result index() {
String s= "Hello Mr.View";
String st[] = {"firstValue","second","third","fourth"};
return ok(index.render(st));
}
}
and my template is:
@(message: String)
@import helper._
@import models._
@import java.sql._
<h1>@message </hl>
How can I resolve this error?
Upvotes: 1
Views: 1002
Reputation: 3963
You need to declare the parameter as a String-Array. I'm assuming you use the default templating system of the framework. It should look something like this:
@(message: Array[String])
@import helper._
@import models._
@import java.sql._
<h1>@message </hl>
Upvotes: 1