zoukankan      html  css  js  c++  java
  • 将平台升至 Spring 5.3.9+velocity2.3+velocitytools3.1

    在 Spring 5.3.9下升级 Velocity 1.7.x 至 velocity2.3 + velocity-tools3.1 出现的问题,记录中...

    spring-webmvc-4.3.9.RELEASE.jar 中 org/springframework/web/servlet/view/velocity 下
    VelocityConfig.java
    VelocityConfigurer.java
    VelocityLayoutView.java
    VelocityLayoutViewResolver.java
    VelocityToolboxView.java
    VelocityView.java
    VelocityViewResolver.java
    spring.vm
    和 spring-context-support-4.3.9.RELEASE.jar中 org/springframework/ui/velocity下
    SpringResourceLoader.java
    VelocityEngineFactory.java

    修改部分源码 其中VelocityToolboxView.java类中 第40行,

    protected Context createVelocityContext(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
        throws Exception
      {
        ChainedContext velocityContext = new ChainedContext(new VelocityContext(model), getVelocityEngine(), request, response, getServletContext());
        if (getToolboxConfigLocation() != null)
        {
          ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
            getServletContext(), getToolboxConfigLocation());
          Map<String, Object> toolboxContext = toolboxManager.getToolbox(velocityContext);
          //将Map<?, ?>替换成了Map<String, Object>,避免类型转换错误
          velocityContext.setToolbox(toolboxContext);
        }
        return velocityContext;
      }
    

    问题1:commons-digester-2.x 升级至 commons-digester3.x

    代码改变

    Velocity 1.x -> ViewToolInfo toolinfo = (ViewToolInfo) digester.peek();

    Velocity 2.x -> ViewToolInfo toolinfo = (ViewToolInfo) getDigester().peek();

    问题2:Apache Commons Lang 2.x 替换为 Apache Commons Lang 3.x

    问题3:commons-collections-3.x 替换为 commons-collections-4.x

    问题4:$velocityCount失效 替换为 $foreach.count

    问题5:configuration key 'resource.loader' has been deprecated in favor of 'resource.loaders'

  • 相关阅读:
    简明Python3教程 12.问题解决
    简明Python3教程 11.数据结构
    【SPOJ 694】Distinct Substrings
    【codeforces Manthan, Codefest 17 C】Helga Hufflepuff's Cup
    【CF Manthan, Codefest 17 B】Marvolo Gaunt's Ring
    【CF Manthan, Codefest 17 A】Tom Riddle's Diary
    【SPOJ 220】 PHRASES
    【POJ 3261】Milk Patterns
    【POJ 3294】Life Forms
    【POJ 1226】Substrings
  • 原文地址:https://www.cnblogs.com/interdrp/p/15683331.html
Copyright © 2011-2022 走看看