【问题标题】:Play framework: type Integer is deprecated: use java.lang.Integer instead播放框架:不推荐使用 Integer 类型:改用 java.lang.Integer
【发布时间】:2013-02-01 02:31:56
【问题描述】:

由于 PlayFramework 似乎不允许路由中的原始 Java 类型(例如 int、long),我不得不在路由中使用 Integer,例如:

GET /paginate/:page controllers.Foo.paginate(page: Integer)

但是,在启动应用程序时,我收到大量警告:

[warn] /project/target/scala-2.9.1/src_managed/main/routes_reverseRouting.scala:351: type Integer is deprecated: use java.lang.Integer instead
[warn] def paginate(page:Integer) = new play.api.mvc.HandlerRef(

这到底是怎么回事?我现在是否必须在所有路线中指定java.lang.Integer?还是我错过了什么?

【问题讨论】:

标签: java playframework playframework-2.0


【解决方案1】:

1) 在路由文件中:将“Integer”替换为“Int”。 您可能想要指定一个默认值。示例:

GET  /my/path  controllers.MyController.foo(value:Int ?= 0)

2) 在 (Java) 控制器中:将 Integer 更改为 int

public static Result foo(int value) {}

我发现警告“不推荐使用 Integer 类型:改用 java.lang.Integer”也很混乱。

【讨论】:

  • 谢谢你,你的回答对我们有帮助,我对 scala 不太了解,但我喜欢 Play Framework。
猜你喜欢
  • 2017-09-08
  • 2020-06-23
  • 2018-05-13
  • 1970-01-01
  • 2022-08-09
  • 2015-01-08
  • 2012-02-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多