기본적으로 Playframework 2.2.1 응용 프로그램의 특정 컨트롤러 작업 (controllers.Application.other())에 대한 특정 A 레코드 (루트 도메인 레코드, 예 : http://example.com)로 모든 요청을 라우팅하려고합니다.A 레코드를 Playframework 2.2.x의 특정 컨트롤러 동작으로 어떻게 라우트합니까?
over here 설명에 따라 글로벌 객체에서 onRouteRequest를 재정의하고 거기에 주입 된 경로를 수행해야한다는 것을 알고 있습니다.
하지만 제 인생에서 제임스 로퍼 (James Roper)의 예가 제대로 작동하지 않습니다 (Playframework 버전 때문이라고 생각합니다). 다음과 같이 오버라이드 (override) 기능은 같습니다 나는 또한 시도
public static Result other() {
return ok(views.html.indexOther());
}
:
type mismatch; found : play.mvc.Result required: play.api.mvc.Handler
내 controllers.Application.other 액션은 페이지 렌더링 매우 기본적인 : 산출
import ....
object Global extends WithFilters(requireSSL, new GzipFilter()) with GlobalSettings {
override def onRouteRequest(request: RequestHeader): Option[Handler] = {
(request.method, request.path) match {
case ("GET", "example.com") => Some(controllers.Application.other)
case _ => super.onRouteRequest(request)
}
}
}
....
controllers.Application.other를 변경하는 것 to controllers.routes.Application.other 그러나 n 그것은 그것이 play.api.mvc.Handler 대신에 ... 전화를 필요로한다고 말합니다. 나는 예상 할 것입니다.
Playframework 2.2.1에서 요청 헤더의 변경 측면에 대해 this post이 발견되어 문제를 해결하는 데 도움이 될 것이라고 생각하지만 요청을 리디렉션하려는 컨트롤러 동작을 머리에 감쌀 수 없습니다. . play.api.mvc.Handler :(
어떤 도움이나 설명으로 대단히 감사합니다
'controllers.Application.other'는 어떻게 생겼습니까? – mantithetical
단순히 페이지를 렌더링하고 그 결과를 반환합니다. 나는 그 질문에 그것을 포함시킬 것이다. –
앱에 스칼라와 자바가 혼합되어있는 이유가 있습니까? 이것은 귀하의 질문에 대답하지 않지만 def index = {...}로 Application.scala를 사용하면 오류를 제거합니다. – mantithetical