在播放 scala 中找不到 favicon.ico 问题 [英] can't find favicon.ico issue in play scala

查看:18
本文介绍了在播放 scala 中找不到 favicon.ico 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试了一个 play 2.3.4 应用程序,在控制台中它抱怨以下内容:

I have tested a play 2.3.4 app, and in the console it complains the following:

! @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 的地方.是否在某个图书馆使用?

Then I searched all the source code and can't find anywhere used favicon.ico. Is it used in some library?

我在 slick 中使用的库.库配置如下:

The library I used in slick. The library configuration is as below:

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放错地方了?

In the route file, I added the following per biesior's reply. But it still complain the same error.Did I put the favicon.ico on the wrong place?

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

推荐答案

每个浏览器在访问地址时都会查找 favicon.ico.只需将该文件添加到您的 public 文件夹并添加一个路由:

Every browser looks for favicon.ico when visiting the address. Just add that file to your public folder and add a route:

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

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

TIP: it can be also png file - in default new PlayJava or PlayScala project it can be found in public/images/favicon.png

这篇关于在播放 scala 中找不到 favicon.ico 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆