I have some query parameters that have dashes in their names. When I attempt to write anything like
parameter('name-with-dash.as[String])
...it doesn't recognize anything after the first dash as being part of the parameter name.
Adding extra single quotes doesn't solve the problem:
parameter(''name-with-dash'.as[String])
Using double quotations around the name-with-dashes
doesn't fix the problem either, I just get an expected ')'
message where the '
normally is at the front.
parameter('"name-with-dash".as[String])
If I ignore the single quote at the beginning, intellij doesn't show any errors but I get a compilation error that looks like this:
Error:(27, 17) type mismatch; found : String("Name-With-Dash")
required: ?{def as: ?} Note that implicit conversions are not applicable because they are ambiguous:
both method _string2NR in trait ToNameReceptacleEnhancements of type(string: String)akka.http.scaladsl.common.NameReceptacle[String]
and method validateModel in object SomeObject of type (value: String)akka.http.scaladsl.server.Directive1[String]
are possible conversion functions from String("Name-With-Dash") to ?{def as: ?}
parameter("Name-With-Dash".as[String]).flatMap(p => provide[SomeIdentifier](SomeIdentifier(p))) |
FIXED:
This was fixed using the following form
parameter("name-with-dash")
ie. with only double quotes and no .as[String]
A simple
parameter("name-with-dash".as[String])
works for me
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.