“无效的版本格式” p.nettyException 与 play 2.2.1

Nul*_*oet 5 playframework playframework-2.2

我的路线文件看起来像

GET     /                           controllers.Application.index()
POST    /get_token                  controllers.Application.getToken()
Run Code Online (Sandbox Code Playgroud)

GET '/' 工作正常。但是,“/get_token”的 POST 失败并显示以下错误消息。

[error] p.nettyException - Exception caught in Netty
java.lang.IllegalArgumentException: invalid version format: =D??$_!HB?H??W(?+?/????
    at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:102) ~[netty.jar:na]
    at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na]
    at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na]
    at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na]
    at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na]
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na]
Run Code Online (Sandbox Code Playgroud)

我正在使用 play-2.2.1。
我比较新玩。有人可以帮我吗?

提前致谢!

Ste*_*eve 6

您是通过 https 连接吗?如果是这样,您可能没有设置证书。

最简单的解决方法是通过 http 而不是 https 进行连接。不过,如果您确实想要 https,您可以生成一个自签名证书:

keytool -genkey -alias MyKey -keyalg RSA -keysize 2048 -keystore keystore.jks play -Dhttps.port=9443 -Dhttps.keyStore=keystore.jks -Dhttps.keyStorePassword=password run