2

如你所知,玩!在 2.2.0 版本中引入了 Gzip 编码。
不幸的是,在更新项目和更新播放后,它不起作用。

[error] ...\app\Global.scala:4: object filters is not a member of package play
[error] import play.filters.gzip.GzipFilter
[error]             ^
[error] ...\app\Global.scala:8: not found: type GzipFilter
[error] object Global extends WithFilters(new GzipFilter) with GlobalSettings {
[error]                                       ^
[error] two errors found
[error] (compile:compile) Compilation failed

即使我创建项目表单控制台它也不起作用play new TEST

但是,在C:\play-2.2.0\framework\src\play-filters-helpers\src\main\scala\play\filters\gzip我同时拥有Gzip.scalaGzipFilter.scala

我的\app\Global.scala样子是这样的:

import play.api._
import play.api.mvc._
import play.api.mvc.Results._
import play.filters.gzip.GzipFilter
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

object Global extends WithFilters(new GzipFilter) with GlobalSettings {
    override def onStart(app: Application) {
        Logger.info("Application has started")
    }

    override def onStop(app: Application) {
        Logger.info("Application shutdown")
    }

    override def onError(request: RequestHeader, ex: Throwable) = Future { InternalServerError("{}") }
    override def onBadRequest(request: RequestHeader, error: String) = Future { BadRequest("{}") }
    override def onHandlerNotFound(request: RequestHeader) = Future { NotFound("{}") }
}

我究竟做错了什么?有没有人让它工作?

4

1 回答 1

17

Build.scala中,只需将“过滤器”添加到您的应用依赖项

val appDependencies = Seq(
  jdbc, cache, filters, ...
)

或者,如果您使用build.sbt进行操作

libraryDependencies ++= Seq(
  jdbc, cache, filters, ...
)
于 2013-10-03T14:13:26.863 回答