samtiger


          QQ:418148757
          Name:yangchuan
          數(shù)據(jù)加載中……
          struts2的小bug

          struts2.1.6的時候,有編碼問題,主要是因?yàn)樗言O(shè)置編碼的那行代碼沒放在最前面。
          struts2.2.1的時候,又出來一個低級bug,那就是一直以來模板的加載都是先查找web.xml中查抄templatePath的配置值,然后才從web應(yīng)用目錄查找,最后才是從class和jar中查找。結(jié)果在2.2.1中就犯了一個低級bug,那就是永遠(yuǎn)找不到web應(yīng)用目錄中,代碼在:org.apache.struts2.views.freemarker.FreemarkerManager.class中
              
          public void init(ServletContext servletContext) throws TemplateException {
              this.config = createConfiguration(servletContext);

              this.config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
              this.contentType = "text/html";

              this.wrapper = createObjectWrapper(servletContext);
              if (LOG.isDebugEnabled())
                LOG.debug("Using object wrapper of class " + this.wrapper.getClass().getName(), new String[0]);

              this.config.setObjectWrapper(this.wrapper);

              this.templatePath = servletContext.getInitParameter("TemplatePath");
              if (this.templatePath == null)
                this.templatePath = servletContext.getInitParameter("templatePath");

              if (this.templatePath == null)
                this.templatePath = "class://";
              this.config.setTemplateLoader(createTemplateLoader(servletContext, this.templatePath));

              loadSettings(servletContext);
            }
              
          protected TemplateLoader createTemplateLoader(ServletContext servletContext, String templatePath)
            {
              TemplateLoader templatePathLoader = null;
              try
              {
                if (templatePath.startsWith("class://"))
                {
                  templatePathLoader = new ClassTemplateLoader(super.getClass(), templatePath.substring(7));
                } else if (templatePath.startsWith("file://"))
                  templatePathLoader = new FileTemplateLoader(new File(templatePath));
              }
              catch (IOException e) {
                LOG.error("Invalid template path specified: " + e.getMessage(), e, new String[0]);
              }

              if (templatePathLoader != null);
              return new MultiTemplateLoader(new TemplateLoader[] { new WebappTemplateLoader(servletContext), new StrutsClassTemplateLoader() });
            }

          不過,這個問題已經(jīng)在2.3的版本中修復(fù)過來了。

          posted on 2012-04-10 23:13 sam.chuan.yang 閱讀(850) 評論(1)  編輯  收藏

          評論

          # re: struts2的小bug 2013-01-22 12:56 123213

          aaaaaaaaaaaaaaaaaaaaaaadddddddddd
            回復(fù)  更多評論    

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 九龙坡区| 原阳县| 星座| 葫芦岛市| 明溪县| 荣昌县| 平安县| 出国| 宿松县| 华容县| 宜阳县| 屏边| 怀仁县| 伊金霍洛旗| 宣威市| 文安县| 双江| 富蕴县| 奎屯市| 南郑县| 郴州市| 浮山县| 疏勒县| 璧山县| 营口市| 湛江市| 黑龙江省| 临沧市| 闽清县| 民勤县| 酉阳| 佛冈县| 行唐县| 随州市| 都江堰市| 克东县| 晋江市| 县级市| 清流县| 金门县| 桐城市|