有一些网址,例如:
http://localhost:9000/images/111111.jpg
http://localhost:9000/images/222222.png
http://localhost:9000/images/333333.gif
它们将被映射到一个方法:
def showImage(id: String) = Action {
val image = Image.findById(id).get
Ok.sendFile(new File(image.path)
}
请注意,这id
是文件名中唯一显示在 url: 111111
, 222222
,中的部分333333
所以我在路由中写了一个映射:
GET /images/$id<\w+>.* controllers.Images.showImage(id)
在part$id<\w+>.*
中,id
匹配id,.*
匹配后缀会被忽略。
但是语法不正确,错误信息是:
Identifier expected
如何解决?