PLAY框架开发中文手册2010-03-19 11:16PLAY开发中文手册
PLAY开发实战中文手册
PLAY功能中文手册
PLAY中文API手册
有需要的请MSN联系:hmguo@hotmail.com
Controllers
执行模板:
public class Clients extends Controller {
public static void index() {
render();
}
}
路径:app/views/Clients/index.html
app/views/Controller/(action names) .html
数据添加到模板范围:
using the renderArgs object。使用renderArgs对象。
public class Clients extends Controller {
public static void show(Long id) {
Client client = Client.findById(id);
renderArgs.put("client", client);
render();
}
}
模板使用:<h1>Client ${client.name}</h1>
更简单的办法:
直接用render(...)方法。
public static void show(Long id) {
Client client = Client.findById(id);
render(client);
}
进一步:
public static void show(Long id) {
Client client = Client.findById(id);
render(id, client);
}
指定另一个模板:
不希望使用默认模板,使用自己指定的模板。
public static void show(Long id) {
Client client = Client.findById(id);
render("Clients/showClient.html", id, client);
}
重定向到另一个URL:
使用redirect(...)。
public static void index() {
redirect("http://www.zenexity.fr");
}
不支持:Forward。(因为没有servlet)注:
一个HTTP请求只能调用一个动作,如果你需要调用另一个动作,重定向浏览器URL,调用另一个动作。
拦截:
@Before @After @Finally
These methods have to be static but not public.
添加更多拦截器,使用@With。
测试@Test
An HTTP request:
1.The URI path: in /clients/1541, 1541 is dynamic part of the URI Pattern.
2.The Query String: /clients?id=1541.
3.The request body: if the request was sent from an HTML form, the request body contains the form data encoded as x-www-urlform-encoded.
package controllers;
import models.Client;
import play.mvc.Controller;
public class Clients extends Controller {
public static void show(Long id) {
Client client = Client.findById(id);
render(client);
}
public static void delete(Long id) {
Client client = Client.findById(id);
client.delete();
}
}
Each public, static method in a Controller is called an action. The signature for an action method is always :
public static void action_name(params...);
render(...)是一个执行结果的方法,并显示一个模板。
import play.mvc.Controller;
params
public static void show() {
String id = params.get("id");
String[] names = params.getAll("names");
}
public static void show() {
Long id = params.get("id", Long.class);
}
public static void show(Long[] id) {
for(String anId : id) {
System.out.println(id);
}
}
public static void show(List<Long> id) {
for(String anId : id) {
System.out.println(id);
}
}
Models域对象模型
这一层是商业软件的核心。该模型在一个应用程序的中心地位。负责代表的业务概念,有关业务情况的信息和业务规则。
分享到:
相关推荐
play手册 play框架手册 play框架 play文档
PLAY框架入门级学习手册,有兴趣了解JAVA PLAY框架的可以看下
Play框架手册
play框架是Java一站式web开发框架,附件是学习手册一份,帮助开发者快速上手该框架。
Play框架中文文档.pdf
play框架jar包,java开发人员使用play框架开发项目时的必备jar包
11.在play框架里使用Ajax - 94 - 通过jsAction标签使用jQuery - 95 - 12. Internationalization国际化支持 - 96 - 仅使用 UTF-8! - 96 - 国际化你的信息 - 96 - 通过应用程序定义支持的语言 - 96 - 依照你的区域定义...
此资源是整个play框架外加一个helloworld小例子,下载解压到文件夹中可以直接进行play框架开发。
play框架 2.1 api
play框架 ajax
carplay开发说明文档,汽车上用的carplay连接说明资料。
在Play框架中,商业逻辑在domain model层里进行管理,Web客户端不能直接调用这些代码,domain对象的功能作为URI资源暴露出来。 客户端使用HTTP协议提供的统一API来暗中操作这些底层的商业逻辑实现资源的维护。然而,...
play框架的搭建步骤,是我自己学习的总结
在Eclipse中使用play框架,并对mysql数据库进行简单的增删改查操作的javaweb项目,主要目的是给学习play框架的新手提供一个简单的例子,帮助其熟悉框架。
play框架基于CRDU的一个简单demo。附数据库文件。使用的是MySQL数据库。
这是play框架的注解的简单介绍,里面有许多注解和使用方法
scala PLAY 框架 sbt仓库,国外链接太慢,下载这个放入cache或者cache同级目录local下(local自己新建)
[Manning Publications] Play 框架开发 (Scala 实现) (英文版) [出版日期] 2013年10月11日[图书页数] 328页 [图书语言] 英语[图书格式] PDF 格式
play框架文档(英文版) play框架介绍请谷歌一下