无法在游戏中找到favicon.ico问题

时间:2014-09-13 09:53:43

标签: scala playframework

我测试了一款播放2.3.4应用,并在控制台中抱怨以下内容:

! @6jg7imio5 - Internal server error, for (GET) [/favicon.ico] ->

play.api.Application$$anon$1: Execution exception[[NoSuchElementException: key not found: favicon.ico]]
    at play.api.Application$class.handleError(Application.scala:296) ~[play_2.10-2.3.0.jar:2.3.0]
    at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.10-2.3.0.jar:2.3.0]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [play_2.10-2.3.0.jar:2.3.0]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [play_2.10-2.3.0.jar:2.3.0]
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33) [scala-library.jar:na]
Caused by: java.util.NoSuchElementException: key not found: favicon.ico
    at scala.collection.MapLike$class.default(MapLike.scala:228) ~[scala-library.jar:na]
    at scala.collection.AbstractMap.default(Map.scala:58) ~[scala-library.jar:na]
    at scala.collection.MapLike$class.apply(MapLike.scala:141) ~[scala-library.jar:na]
    at scala.collection.AbstractMap.apply(Map.scala:58) ~[scala-library.jar:na]
    at controllers.Application$$anonfun$list$1$$anonfun$apply$7$$anonfun$apply$8.apply(Application.scala:68) ~[classes/:2.3.0]

然后我搜索了所有的源代码,找不到任何使用过的favicon.ico。它是否在某些库中使用?

我在光滑中使用的库。库配置如下:

libraryDependencies ++= Seq(
    "com.typesafe.play" %% "play-slick" % "0.7.0",
    "org.slf4j" % "slf4j-nop" % "1.6.4",
    "joda-time" % "joda-time" % "2.3",
    "org.joda" % "joda-convert" % "1.5",
    "com.github.tototoshi" %% "slick-joda-mapper" % "1.1.0",
    jdbc,
    anorm
)

更新

oracle@SomeHost ~/activator-1.2.10/abb_web_1/public $ tree
.
├── images
│   └── favicon.ico
├── javascripts
│   ├── forms.js
│   └── jquery.js
└── stylesheets
    ├── bootstrap.min.css
    └── main.css

在路线文件中,我根据biesior的回复添加了以下内容。但是它仍然抱怨同样的错误。我把favicon.ico放在了错误的地方吗?

GET     /favicon.ico                controllers.Assets.at(path="/public", file="favicon.ico")

2 个答案:

答案 0 :(得分:9)

访问该地址时,每个浏览器都会查找favicon.ico。只需将该文件添加到public文件夹并添加路线:

GET  /favicon.ico   controllers.Assets.at(path="/public", file="favicon.ico")

提示:它也可以是png文件 - 在默认的新PlayJava或PlayScala项目中可以找到它public/images/favicon.png

答案 1 :(得分:0)

你应该将路径表示为 controllers.Assets.at(path =&#34; / public / images&#34;,file =&#34; favicon.ico&#34;) < / p>