samtiger


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

          struts2.1.6的時候,有編碼問題,主要是因為他把設(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 閱讀(843) 評論(1)  編輯  收藏

          評論

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

          aaaaaaaaaaaaaaaaaaaaaaadddddddddd
            回復(fù)  更多評論    

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 安康市| 运城市| 新乡县| 邹平县| 土默特右旗| 固安县| 农安县| 北宁市| 黄大仙区| 波密县| 枝江市| 睢宁县| 饶河县| 新竹县| 化州市| 无锡市| 志丹县| 福安市| 横山县| 乌拉特前旗| 白沙| 东阳市| 永昌县| 阿拉善右旗| 鹤庆县| 彭阳县| 天长市| 宁国市| 澄迈县| 宜州市| 桑日县| 陵水| 方山县| 繁昌县| 二连浩特市| 常山县| 凉城县| 河北区| 内江市| 新巴尔虎右旗| 巴彦县|