开发者社区 问答 正文

s2sh项目的设计

最近做了几个s2sh的项目,感觉自己欠缺还是很多。

以下是几个需要解决的问题:

1.spring事务管理

2.struts2中actionContext对象的滥用

3.struts2标签使用

4.拦截器的使用

5.session的滥用

6.json解析

思路比较凌乱,等慢慢整理,提醒自己需要强化的内容。

先从Action开始说起吧,数据层方面的设计,我还需要整理下。

展开
收起
a123456678 2016-03-12 18:06:16 1886 分享 版权
1 条回答
写回答
取消 提交回答
  • /**
     * 系统上下文(线程级别)
     * @author Jeff.sui
     * @since 2011.4.24
     *
     */
    public class AOLContext {
        private ThreadLocal<Map<String,Object>> additionalContextHolder = new ThreadLocal<Map<String,Object>>();
        private static AOLContext inst = null;
        public AOLContext(){
            
            
        }
        public static AOLContext getContext(){
            if (inst==null) {
                inst = new AOLContext();
                
            }
            return inst;    
        }
        
        public Map<String,Object>  getApplication(){
            return ActionContext.getContext().getApplication();
        }
        
        public Locale getLocale() {
            return ActionContext.getContext().getLocale();
        }
        
        public Map<String, Object> getParameters() {
            return ActionContext.getContext().getParameters();
        }
    
        public HttpServletRequest getRequest() {
            return ServletActionContext.getRequest();
        }
    
        public HttpServletResponse getResponse() {
            return ServletActionContext.getResponse();
        }
    
        public ServletContext getServletContext() {
            return ServletActionContext.getServletContext();
        }
        /**
         * 从HttpRequest中获得指定参数,并以Integer形式返回。
         * @param paramName 参数名
         * @return 参数值
         */
        public Integer getReqParaAsInt(String paramName) {
            String pv = ServletActionContext.getRequest().getParameter(paramName);
            if(pv!=null)
            {
                return Integer.valueOf(pv);
            }
            return null;
        }
        /**
         * 从HttpRequest中获得指定参数,并以Short形式返回。
         * @param paramName 参数名
         * @return 参数值
         */
        public Short getReqParaAsShort(String paramName) {
            String pv = ServletActionContext.getRequest().getParameter(paramName);
            if(pv!=null)
            {
                return Short.valueOf(pv);
            }
            return null;
        }
    
        /**
         * 从HttpRequest中获得指定参数,并以字符串形式返回。
         * @param paramName 参数名
         * @return 参数值
         */
        public String getReqParaAsStr(String paramName) {
            return ServletActionContext.getRequest().getParameter(paramName);
        }
        /**
         * 向系统上下文中添加一个对象
         * @param key 对象KEY
         * @param value 对象实例
         */
        public void put(String key, Object value)
        {
            additionalContextHolder.get().put(key, value);
        }
        /**
         * 从系统上下文中获得指定Key的对象
         * @param key KEY
         * @return KEY对应的对象
         */
        public Object get(String key)
        {
            return additionalContextHolder.get().get(key);
        }
        void init()
        {
            additionalContextHolder.set(new HashMap<String,Object>());
        }
        
        void clear()
        {
            additionalContextHolder.set(null);
        }
        
    }
    2019-07-17 19:01:19
    赞同 展开评论
问答分类:
问答地址: