当前位置: 首页>>代码示例>>Java>>正文


Java Controller.getPara方法代码示例

本文整理汇总了Java中com.jfinal.core.Controller.getPara方法的典型用法代码示例。如果您正苦于以下问题:Java Controller.getPara方法的具体用法?Java Controller.getPara怎么用?Java Controller.getPara使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jfinal.core.Controller的用法示例。


在下文中一共展示了Controller.getPara方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: intercept

import com.jfinal.core.Controller; //导入方法依赖的package包/类
@Override
public void intercept(ActionInvocation ai) {
    Controller controller = ai.getController();
    String token = controller.getPara("token");
    if (StringUtils.isEmpty(token)) {
        controller.renderJson(new BaseResponse(Code.ARGUMENT_ERROR, "token can not be null"));
        return;
    }

    User user = TokenManager.getMe().validate(token);
    if (user == null) {
        controller.renderJson(new BaseResponse(Code.TOKEN_INVALID, "token is invalid"));
        return;
    }
    
    controller.setAttr("user", user);
    ai.invoke();
}
 
开发者ID:kevin09002,项目名称:jfinal-api-scaffold,代码行数:19,代码来源:TokenInterceptor.java

示例2: checkSignature

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 检测签名
 */
private boolean checkSignature(Controller controller) {
	String signature = controller.getPara("signature");
	String timestamp = controller.getPara("timestamp");
	String nonce = controller.getPara("nonce");
	if (StrKit.isBlank(signature) || StrKit.isBlank(timestamp) || StrKit.isBlank(nonce)) {
		controller.renderText("check signature failure");
		return false;
	}
	
	if (SignatureCheckKit.me.checkSignature(signature, timestamp, nonce)) {
		return true;
	}
	else {
		log.error("check signature failure: " +
				" signature = " + controller.getPara("signature") +
				" timestamp = " + controller.getPara("timestamp") +
				" nonce = " + controller.getPara("nonce"));
		
		return false;
	}
}
 
开发者ID:touzi,项目名称:weChat,代码行数:25,代码来源:MsgInterceptor.java

示例3: configServer

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 配置开发者中心微信服务器所需的 url 与 token
 * @return true 为config server 请求,false 正式消息交互请求
 */
public void configServer(Controller c) {
	String msg_signature = c.getPara("msg_signature");
       String timestamp = c.getPara("timestamp");
       String nonce = c.getPara("nonce");
       String echostr = c.getPara("echostr");
       
       //非加密验证
       boolean isOk = SignatureCheckKit.me.checkSignature(msg_signature, timestamp, nonce,echostr);
       
	if (isOk){
		WxCryptUtil pc = getWxCryptUtil();
		echostr= pc.decrypt(echostr);
		
		log.info("验证成功,解密后的echostr:"+echostr);
		c.renderText(echostr);
	}
	else
		log.error("验证失败:configServer!");
}
 
开发者ID:jaiiye,项目名称:weixin-moffice,代码行数:24,代码来源:CorpInterceptor.java

示例4: checkSignature

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 检测签名
 */
private boolean checkSignature(Controller controller) {
	String signature = controller.getPara("signature");
	String timestamp = controller.getPara("timestamp");
	String nonce = controller.getPara("nonce");
	if (StrKit.isBlank(signature) || StrKit.isBlank(timestamp) || StrKit.isBlank(nonce)) {
		controller.renderText("check signature failure");
		return false;
	}
	
	if (SignatureCheckKit.me.checkSignature(signature, timestamp, nonce)) {
		return true;
	}
	else {
		logger.error("check signature failure: " +
				" signature = " + controller.getPara("signature") +
				" timestamp = " + controller.getPara("timestamp") +
				" nonce = " + controller.getPara("nonce"));
		
		return false;
	}
}
 
开发者ID:JackFish,项目名称:jfinal-weixin,代码行数:25,代码来源:MsgInterceptor.java

示例5: checkSignature

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 检测签名
 */
private boolean checkSignature(Controller c) {
	String signature = c.getPara("signature");
	String timestamp = c.getPara("timestamp");
	String nonce = c.getPara("nonce");
	
	if (StrKit.isBlank(signature) || StrKit.isBlank(timestamp) || StrKit.isBlank(nonce)) {
		c.renderText("check signature failure");
		return false;
	}
	
	if (SignatureCheckUtil.checkSignature(WcCache.getWxBase("").getToken(), signature, timestamp, nonce)) {
		return true;
	} else {
		logger.error("check signature failure: " +
				" signature = " + c.getPara("signature") +
				" timestamp = " + c.getPara("timestamp") +
				" nonce = " + c.getPara("nonce"));
		
		return false;
	}
}
 
开发者ID:efsn,项目名称:wechat-standard,代码行数:25,代码来源:MsgInterceptor.java

示例6: validate

import com.jfinal.core.Controller; //导入方法依赖的package包/类
@Override
protected void validate(Controller c) {
	System.out.println("~~~~LoginEmail=" + c.getSessionAttr(Constants.ATTR_LOGIN_EMAIL));
	System.out.println("~~~~SessionID=" + c.getSession().getId());
	
	if(	c.getSession().getAttribute(Constants.ATTR_LOGIN_EMAIL) == null || 
		c.getSession().getAttribute(Constants.ATTR_LOGIN_EMAIL).toString().length() == 0	) {
		if(c.getPara("email") != null) {
			validateEmail("email", "errMsg", "邮件地址错误");
			validateRequiredString("password", "errMsg", "登录密码不能为空");
			
			// varify exists
			UserDAO userDao = new MySQLUserDAO();
			User user = userDao.query(c.getPara("email"));
			if(user == null || !StringUtils.equals(user.getPassword(), c.getPara("password"))) {
				addError("errMsg", "登录信息有误");
			}
		}  else {
			validateRequiredString("email", "errMsg", "");
		}
	}
}
 
开发者ID:RangerWolf,项目名称:Finance-News-Helper,代码行数:23,代码来源:LoginActionValidator.java

示例7: validate

import com.jfinal.core.Controller; //导入方法依赖的package包/类
@Override
protected void validate(Controller c) {
	validateRequiredString(Constants.ATTR_USER_STOCK, ERROR_MSG_KEY, "缺少股票代码");
	validateRegex(Constants.ATTR_USER_STOCK, "/^[,0-9]*$/", ERROR_MSG_KEY, "股票代码错误");
	validateRequiredString(Constants.ATTR_USER_KEYWORD, ERROR_MSG_KEY, "缺少关键字");
	validateRegex(Constants.ATTR_USER_KEYWORD, "/^[,a-zA-z0-9\u4E00-\u9FA5]*$/", ERROR_MSG_KEY, "只能中文、英文或者数字,不支持标点符号");
	
	// keyword的长度不能超过20个关键字
	String keyword = c.getPara(Constants.ATTR_USER_KEYWORD);
	String[] words = keyword.split(","); 
	if(words.length > 20) {
		addError(ERROR_MSG_KEY, "不能超过20个关键字");
	} else {
		boolean flagOfLengthVarify = true;
		for(String word : words ) {
			if(word.trim().length() > 7 || word.trim().length() < 2) {
				flagOfLengthVarify = false;
				break;
			}
		}
		if(!flagOfLengthVarify) {
			addError(ERROR_MSG_KEY, "关键字的长度应该在2~7之间");
		}
	}
}
 
开发者ID:RangerWolf,项目名称:Finance-News-Helper,代码行数:26,代码来源:UserUpdateValidator.java

示例8: validate

import com.jfinal.core.Controller; //导入方法依赖的package包/类
@Override
protected void validate(Controller c) {
	validateRequiredString("user.username", "category_error", "用户名不能为空");
	int userId = 0;

	String email = c.getPara("user.email");
	String username = c.getPara("user.username");
	Integer[] is = c.getParaValuesToInt("user_role");
	int id = 0;
	if (email.length() != 0) {
		validateEmail("user.email", "text_error", "email格式不正确");
	}
	if (is == null) {
		addError("role_error", "必须选择一个角色");
	}
	if (userId == 0) {
		validateRequiredString("user.password", "text_error", "密码不能为空");
		validateEqualField("user.password", "vpassword", "text_error", "密码与确认密码不匹配");
	}

	if (username.length() != 0) {
		Record count = null;
		count = Db
				.findFirst("select count(id) as count from user where username='"
						+ username + "' and id<>" + id);
		if (count.getLong("count") != 0) {
			addError("codeRepeat_error", "已存在此用户");
		}
		;
	}
}
 
开发者ID:yaokwok,项目名称:loveabc,代码行数:32,代码来源:UserFormValidator.java

示例9: intercept

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 参数处理
 * 1. 参数为空时直接调用
 * 2. 参数不为空时先判断是否使用?间隔,使用了?间隔先split一下参数,拿到?之前的参数,查找是否有这个action。没有就404,有就直接invoke
 */
@Override
public void intercept(Invocation ai) {
	// 获取controller
	Controller controller = ai.getController();
	// 获取controller 的参数
	String param = controller.getPara();
	if (param == null) {
		ai.invoke();
	} else {
		String[] params = null;
		if (param.contains("?")) {
			params = param.split("?");
		}
		if (params != null) {
			param = params[0];
		}
		
		boolean contained = false;
		Method[] methods = controller.getClass().getMethods();
		for (Method method : methods) {
			if (param.equals(method.getName())) {
				contained = true;
				break;
			}
		}
		if (!contained){
			controller.renderError(404);
		} 
		ai.invoke();
	}
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:37,代码来源:NotFoundActionInterceptor.java

示例10: getForm

import com.jfinal.core.Controller; //导入方法依赖的package包/类
public static Form getForm(String tableName, Controller c, String... params)
{
	Form form = new Form(tableName);

	for (String key : params)
	{
		form.fromMap.put(key, c.getPara(key, null));
	}

	Enumeration<String> names = c.getParaNames();

	while (names.hasMoreElements())
	{
		String name = names.nextElement();
		if (name.contains(".")) form.addFrom(form, name, c.getPara(name, null));
		else if(name.contains("-")) form.addFrom(form, name, c.getPara(name,null));
	}
	
	form.page  =c.getParaToInt("page");
	form.count =c.getParaToInt("count");
	
	form.sortName =c.getPara("sortName");
	form.sortOrder =c.getPara("sortOrder");
	
	

	return form;
}
 
开发者ID:jayqqaa12,项目名称:jbase,代码行数:29,代码来源:Form.java

示例11: validate

import com.jfinal.core.Controller; //导入方法依赖的package包/类
protected void validate(Controller c) {
	validateEmail("sysUser.email", "registerEmailMsg", "邮箱不正确.");
	validateRegex("sysUser.user_name", "[a-zA-Z0-9_]{2,8}", "userNameMsg", "用户名的长度介于2-8之间,只能包含数字,字母,下划线");
	validateRegex("sysUser.pwd", "^[a-zA-Z]\\w{5,17}$", "userPassWordMsg", "以字母开头,长度在6~18之间,只能包含字符、数字和下划线");
	validateEqualField("sysUser.pwd", "rePassWord", "rePassWordMsg", "2次输入的密码不一致.");
	String email = c.getPara("sysUser.email");
	if(StringKit.notBlank(email) && SysUser.me.containEmail(email)) {
		addError("registerEmailMsg", "邮箱已经被注册过了:( ");
	}
	String userName = c.getPara("sysUser.user_name");
	if(StringKit.notBlank(userName) && SysUser.me.containUser(userName)) {
		addError("userNameMsg", "用户名已经被注册过了:( ");
	}
}
 
开发者ID:touzi,项目名称:weChat,代码行数:15,代码来源:SysUserValidator.java

示例12: configServer

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 配置开发者中心微信服务器所需的 url 与 token
 * @return true 为config server 请求,false 正式消息交互请求
 */
public void configServer(Controller c) {
	// 通过 echostr 判断请求是否为配置微信服务器回调所需的 url 与 token
	String echostr = c.getPara("echostr");
	String signature = c.getPara("signature");
       String timestamp = c.getPara("timestamp");
       String nonce = c.getPara("nonce");
	boolean isOk = SignatureCheckKit.me.checkSignature(signature, timestamp, nonce);
	if (isOk)
		c.renderText(echostr);
	else
		log.error("验证失败:configServer");
}
 
开发者ID:touzi,项目名称:weChat,代码行数:17,代码来源:MsgInterceptor.java

示例13: checkSignature

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 检测微信加密签名
 * msg_signature结合了企业填写的token、请求中的timestamp、nonce参数、加密的消息体
 */
private boolean checkSignature(Controller controller) {
	String msg_signature = controller.getPara("msg_signature");
	String timestamp = controller.getPara("timestamp");
	String nonce = controller.getPara("nonce");

	if (StrKit.isBlank(msg_signature) || StrKit.isBlank(timestamp) || StrKit.isBlank(nonce)) {
		controller.renderText("check signature failure. (msg_sigature|timestamp|none) not exist ");
		return false;
	}
	
	return true;

}
 
开发者ID:jaiiye,项目名称:weixin-moffice,代码行数:18,代码来源:CorpInterceptor.java

示例14: configServer

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 配置开发者中心微信服务器所需的 url 与 token
 * @return true 为config server 请求,false 正式消息交互请求
 */
public void configServer(Controller c) {
	// 通过 echostr 判断请求是否为配置微信服务器回调所需的 url 与 token
	String echostr = c.getPara("echostr");
	String signature = c.getPara("signature");
	String timestamp = c.getPara("timestamp");
	String nonce = c.getPara("nonce");
	boolean isOk = SignatureCheckKit.me.checkSignature(signature, timestamp, nonce);
	if (isOk)
		c.renderText(echostr);
	else
		logger.error("验证失败:configServer");
}
 
开发者ID:JackFish,项目名称:jfinal-weixin,代码行数:17,代码来源:MsgInterceptor.java

示例15: configServer

import com.jfinal.core.Controller; //导入方法依赖的package包/类
/**
 * 配置开发者中心微信服务器所需的 url 与 token
 * true 为config server 请求,false 正式消息交互请求
 */
public void configServer(Controller c) {
	// 通过 echostr 判断请求是否为配置微信服务器回调所需的 url 与 token
	String echostr = c.getPara("echostr");
	String signature = c.getPara("signature");
       String timestamp = c.getPara("timestamp");
       String nonce = c.getPara("nonce");
       
	boolean isOk = SignatureCheckUtil.checkSignature(WcCache.getWxBase("").getToken(), signature, timestamp, nonce);
	if (isOk)
		c.renderText(echostr);
	else
		logger.error("验证失败:configServer");
}
 
开发者ID:efsn,项目名称:wechat-standard,代码行数:18,代码来源:MsgInterceptor.java


注:本文中的com.jfinal.core.Controller.getPara方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。