Created
December 6, 2011 05:52
-
-
Save lovuikeng/1436927 to your computer and use it in GitHub Desktop.
Scala controller in Spring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://github.com/cbeams/hello-spring-scala/blob/master/src/main/scala/com/vmware/hello/HomeController.scala | |
| import scala.collection._ | |
| @Controller | |
| class HomeController { | |
| val env = new CloudEnvironment | |
| @Autowired var dataSource: DataSource = null | |
| /** | |
| * Simply selects the home view to render by returning its name. | |
| */ | |
| @RequestMapping(value = Array("/"), method = Array(RequestMethod.GET)) | |
| def home(model: mutable.Map[String, String]): String = { | |
| model("dataSource") = dataSource.getConnection.toString | |
| logger.info("Welcome home from " + env.getInstanceInfo().getHost() + ":" + env.getInstanceInfo().getPort()) | |
| "home" | |
| } | |
| } | |
| object HomeController { | |
| val logger = LoggerFactory.getLogger(classOf[HomeController]) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment