---
title: "play-scala试用"
author: "Jamsa"
date: "2011-09-21T11:00:29Z"
tags: []
categories: ["编程语言"]
slug: "play-scala"
draft: false
lastmod: "2011-09-21T11:01:28Z"
id: 1176861
url: "https://jamsa.iteye.com/blog/1176861"
---

看过

[http://www.jtict.com/blog/rails-wicket-grails-play-lift-jsp/](http://www.jtict.com/blog/rails-wicket-grails-play-lift-jsp/)

这个评测之后，简单试用了下play-scala。

 

发现与之前的play-java差异比较大。特点：

1\. 你可以完全使用scala，甚至在页面模板里

2\. 类rails的路由规则配置

3\. anorm仅对jdbc做了简单的封装

4\. 模板被转化为代码，编译期检查。性能应该不会很差（没做测试）

 

也发现两个小问题分别是模板系统和JDBC这两块。

1\. 模板系统的import在windows系统下有问题。

@import utils.\_这样的语句在win下会有问题，是因为换行符的问题引起的

[http://scala.playframework.org/documentation/scala-0.9.1/templates](http://scala.playframework.org/documentation/scala-0.9.1/templates)

底部评论里有人提到

- [![](http://media.disqus.com/uploads/anonusers/894/5492/avatar32.jpg)](http://disqus.com/guest/88e5a9eb011a73ab970ddc8cfb05ff85/)
  
  Freewind [1 month ago](http://scala.playframework.org/documentation/scala-0.9.1/templates#comment-270030440 "Link to comment by Freewind")
  
  "@import utils.\_" can't be compiled. Is it a bug, or do I miss something?
- [![](http://mediacdn.disqus.com/1316468151/images/noavatar32.png)](http://disqus.com/guest/4dd3730f9080e6ebe8ae3ff9e617be03/)
  
  Alex Lee [1 week ago](http://scala.playframework.org/documentation/scala-0.9.1/templates#comment-305006902 "Link to comment by Alex Lee") [in reply to Freewind](http://scala.playframework.org/documentation/scala-0.9.1/templates#comment-270030440 "Jump to comment")
  
  yes, so you need to set your IDE or text editor using  unix style line ending.
- [![](http://mediacdn.disqus.com/1316468151/images/noavatar32.png)](http://disqus.com/google-7717bed61c890a42c6222ebda4e7b099/ "Expand 鹏 李's profile")
  
  鹏 李 [1 month ago](http://scala.playframework.org/documentation/scala-0.9.1/templates#comment-277199939 "Link to comment by 鹏 李") [in reply to Freewind](http://scala.playframework.org/documentation/scala-0.9.1/templates#comment-270030440 "Jump to comment")
  
  It doesn't work if the line separator is "\\r\\n", because the \`importExpression\` defined is "import .\*\\n"

2\. 文档中[anorm](http://scala.playframework.org/documentation/scala-0.9.1/anorm) 的一段MS有语法错误。

case class Country(  
    code:Id\[String], name:String, population:Int, headOfState:Option\[String]  
)  
object Country extends Magic\[Country]().using("Countries")//错误

改成下面这样吧

case class Member(name: String, email: Option\[String])  
object Member extends Magic\[Member](Some("members"))