我正在使用 Java Play 框架并尝试将数组值从 Controller 传递到 View ,但出现错误。我的代码在这里:
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));
}
}
我的模板是:
@(message: String)
@import helper._
@import models._
@import java.sql._
<h1>@message </hl>
如何解决此错误?
最佳答案
您需要将参数声明为字符串数组。我假设您使用框架的默认模板系统。它应该看起来像这样:
@(message: Array[String])
@import helper._
@import models._
@import java.sql._
<h1>@message </hl>
关于java - 如何将字符串值数组从 Controller 传递到 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19655155/