资源简介
play,play framework,java新框架资料大全,让java快速开发不是问题
代码片段和文件信息
package controllers;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import play.Play;
import play.data.binding.Binder;
import play.data.validation.MaxSize;
import play.data.validation.Password;
import play.data.validation.Required;
import play.db.Model;
import play.exceptions.TemplateNotFoundException;
import play.i18n.Messages;
import play.mvc.Before;
import play.mvc.Controller;
import play.mvc.Router;
import play.mvc.Util;
import play.utils.Utils;
import anno.mycrud.ExcludeAction;
import anno.mycrud.ExcludeParams;
import data.validate.MyValidation;
public class MyCRUD extends Application {
@Before
public static void addTypeAndCheck() throws Exception {
// 不允许执行的方法
ExcludeAction excudeMethod = getControllerAnnotation(ExcludeAction.class);
if (excudeMethod != null) {
String[] excludeActions = excudeMethod.value();
String action = request.actionMethod;
for (String excludeAction : excludeActions)
if (excludeAction.equalsIgnoreCase(action))
forbidden();
}
// 不允许绑定的参数
ExcludeParams excludeParams = getControllerAnnotation(ExcludeParams.class);
if (excludeParams != null) {
for (String value : excludeParams.value())
params.remove(value);
}
excludeParams = getActionAnnotation(ExcludeParams.class);
if (excludeParams != null) {
for (String value : excludeParams.value())
params.remove(value);
}
objectType type = objectType.get(getControllerClass());
renderArgs.put(“type“ type);
}
protected static objectType getType() {
return renderArgs.get(“type“ objectType.class);
}
public static void index() {
if (getControllerClass() == MyCRUD.class) {
forbidden();
}
render(“MyCRUD/index.html“);
}
private static final Pattern p = Pattern.compile(“\\[eq\\]“);
/**
* http传入的参数filter对应where条件的规则:
* 1. ‘=‘ 用[eq]替代 如:?type.id[eq]1 表示type.id=1
* @param page
* @param search
* @param searchFields
* @param orderBy
* @param order
*
*/
@Util
public static void list(int page String search String searchFields
String orderBy String order) {
objectType type = objectType.get(getControllerClass());
notFoundIfNull(type);
if (page < 1) {
page = 1;
}
if (StringUtils.isBlank(orderBy)) {
orderBy = “id“;
order = “DESC“;
}
//where条件
String[] filters = params.getAll(“filter“);
String where = Utils.join(filters “and“);
if(StringUtils.isNotBlank(where)){
Matcher matcher = p.matc
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 231776 2011-01-06 01:26 play——demo.rar
文件 1153118 2011-01-05 21:16 playfr
文件 141824 2011-01-06 01:50 Play详细使用文档.doc
文件 15847 2011-06-06 08:24 对play!的CRUD的一次改造MyCRUD.java
文件 1486256 2011-06-14 13:09 play1.1_api.rar
文件 11986402 2011-07-28 23:36 play资料.rar
----------- --------- ---------- ----- ----
15015223 6
评论
共有 条评论