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

查看:126
本文介绍了在play 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?

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

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

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

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