【发布时间】:2016-01-19 10:46:28
【问题描述】:
我的以下代码出错了!!!在 spark.get(new Route("/"). 我是新来的火花任何帮助将不胜感激??任何建议
public static void main(String[] args) {
final Configuration configuration=new Configuration();
configuration.setClassForTemplateLoading(sparkclass.class,"/");
final StringWriter writer=new StringWriter();
Spark.get(new Route("/"){
public Object handle(Request request, Response response) throws Exception {
Template helloTemplate=configuration.getTemplate("hello.ftl");
HashMap<String,Object>mp=new HashMap<String, Object>();
mp.put("name","Sumit");
helloTemplate.process(mp,writer);
System.out.print(writer);
return writer;
}
});
}
【问题讨论】:
-
请贴出错误,否则很难猜到。
-
java:匿名类实现接口;不能有参数这是第号行的错误。 5
-
Spark.get("/", new Route() {...}应该可以代替 -
"java:匿名类实现接口;不能有参数",编译器再明显不过了。实现接口的匿名类如何具有接受参数的构造函数
标签: java maven freemarker