package com.xjcy.test.common;
import java.util.HashMap;
import java.util.Map;
import com.geneqiao.struts.ActionSupport;
import com.geneqiao.struts.views.ModelAndView;
import com.geneqiao.utils.PropertiesReadUntils;
/**
* 公共控制类
*
* @author YYDF
*
*/
public class GlobalController extends ActionSupport
{
private static String basePath = PropertiesReadUntils.getVal("basePath");
private static String imagePath = PropertiesReadUntils.getVal("imagePath");
protected String getOK(String json)
{
this.setCacheJson(json);
return RESULT_JSON_CACHE;
}
protected String getOK(Object... obj)
{
Map<String, Object> jsonMap = new HashMap<String, Object>();
jsonMap.put("success", true);
String key = "";
for (int i = 0; i < obj.length; i++)
{
if (i % 2 == 0)
{
key = (String) obj[i];
}
else
{
jsonMap.put(key, obj[i]);
}
}
this.setJsonMap(jsonMap);
return RESULT_JSON;
}
protected String getView(String name)
{
ModelAndView mav = new ModelAndView();
mav.setViewName(name);
this.setModelAndView(mav);
return RESULT_JSP_VIEW;
}
protected String getView(ModelAndView mav)
{
this.setModelAndView(mav);
return RESULT_JSP_VIEW;
}
protected String getError()
{
return getError(999001);
}
protected String getError(String error)
{
Map<String, Object> jsonMap = new HashMap<String, Object>();
jsonMap.put("success", false);
jsonMap.put("errmsg", error);
this.setJsonMap(jsonMap);
return RESULT_JSON;
}
protected String getError(int errId)
{
Map<String, Object> jsonMap = new HashMap<String, Object>();
jsonMap.put("success", false);
jsonMap.put("errcode", errId);
jsonMap.put("errmsg", ERROR.valueOf(errId).name());
this.setJsonMap(jsonMap);
return RESULT_JSON;
}
protected Integer getUserId()
{
if (getAttribute("userId") == null)
return null;
return Integer.valueOf(getAttribute("userId").toString());
}
protected String getOpenId()
{
Object openId = getAttribute("openId");
if (openId == null)
return null;
return openId.toString();
}
protected String getImagePath()
{
return imagePath;
}
public static String getBasePath()
{
return basePath;
}
}
一个简化版的SSH后端接口框架demo
需积分: 23 153 浏览量
2017-07-24
11:05:56
上传
评论
收藏 1.57MB ZIP 举报
呓语的风
- 粉丝: 12
- 资源: 6
最新资源
- python-leetcode面试题解之第157题用Read4读取N个字符-题解.zip
- python-leetcode面试题解之第156题上下翻转二叉树-题解.zip
- python-leetcode面试题解之第155题最小栈-题解.zip
- python-leetcode面试题解之第153题寻找旋转排序数组中的最小值-题解.zip
- python-leetcode面试题解之第152题乘积最大子数组-题解.zip
- python-leetcode面试题解之第151题反转字符串中的单词-题解.zip
- python-leetcode面试题解之第150题逆波兰表达式求值-题解.zip
- python-leetcode面试题解之第149题直线上最多的点数-题解.zip
- python-leetcode面试题解之第148题排序链表-题解.zip
- python-leetcode面试题解之第147题对链表进行插入排序-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈