我喜欢你的问题,因为它至少对我来说很有创意:) 检查这种方法对我有用:
conf/routes
:
GET /help controllers.Application.helpIndex(lang = "en")
GET /hilfe controllers.Application.helpIndex(lang = "de")
GET /help/:id controllers.Application.helpTopic(lang = "en", id: Long)
GET /hilfe/:id controllers.Application.helpTopic(lang = "de", id: Long)
controllers/Application.java
:
public static Result helpIndex(String lang) {
return ok("Display help's index in " + lang.toUpperCase());
}
public static Result helpTopic(String lang, Long id) {
return ok("Display details of help topic no " + id + " in " + lang.toUpperCase());
}
views/someView.scala.html
:
<a href="@routes.Application.helpIndex("en")">Help index</a><br/>
<a href="@routes.Application.helpIndex("de")">Hilfe index</a><br/>
<a href="@routes.Application.helpTopic("en", 12)">Help topic no 12</a><br/>
<a href="@routes.Application.helpTopic("de", 12)">Hilfe topic no 12</a>