我正在使用 playframework 2.3.8 并且有一个视图类。里面有一个按钮:
<button class="btn btn-default" type="button" onclick="@routes.Application.sendMap(myMap)" method="POST">Send</button>
我想在我的控制器类(Application.java)中的地图上附加一个问题/答案对:
public static Result sendMap(Map<Question, List<Answer>> sendMap){
Question question4 = new Question("ertw", "SendMap Question?", 34, "Tim");
Answer answer41 = new Answer("werw", "ertw", "SendMap Answer 1!", 12, "Oliver");
Answer answer42 = new Answer("tzsdfu", "ertw", "SendMap Answer 2!", 1, "Marcus");
List<Answer> answerList4 = new ArrayList<Answer>();
answerList4.add(answer41);
answerList4.add(answer42);
sendMap.put(question4, answerList4);
return ok(views.html.frageAntwort.render(sendMap));
}
在我的 routes.conf 中,我已将路由添加到控制器类并Map
用作参数:
POST /QuestionMap controllers.Application.sendMap(Map)
但现在我得到了错误:
type mismatch;
found : String
required: java.util.Map[model.Question,java.util.List[model.Answer]]
为什么地图会被转换成字符串?