spring mvc 4+velocity及びカスタムtools


最近のプロジェクトではspring mvcバージョンを使用しました.4.1.6.RELAESEです.
velocity-toolsも私の2 Bのアップグレードによって2.0になりました.
------------------
mvc 3バージョン以上はVlocitytoolsのロードを完了するためにカスタムview Classが必要です.そうでなければエラーを報告します.
このステップでは、ネット上ではすでにshareの方法が出てきました.
<bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
   <!--<property name="viewClass" value="org.springframework.web.servlet.view.velocity.VelocityView"/>-->
   <property name="viewClass" value="com.*.*.utils.VelocityToolView" />
   <property name="prefix" value="/"/>
   <property name="suffix" value=".vm"/>
   <property name="contentType" value="text/html;charset=UTF-8"/>
   <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
</bean>
その中のコードは大体次の通りです.
VelocityToolView VelocityToolboxView {
    Context (Map<StringObject> modelHttpServletRequest requestHttpServletResponse response) Exception {ViewToolContext ctxctx = ViewToolContext(getVelocityEngine()requestresponsegetServletContext())ctx.putAll(model)(.getToolboxConfigLocation() != ) {
            ToolManager tm = ToolManager()tm.setVelocityEngine(getVelocityEngine())tm.configure(getServletContext().getRealPath(getToolboxConfigLocation()))(tm.getToolboxFactory().hasTools(Scope.)) {
                ctx.addToolbox(tm.getToolboxFactory().createToolbox(Scope.))}
            (tm.getToolboxFactory().hasTools(Scope.)) {
                ctx.addToolbox(tm.getToolboxFactory().createToolbox(Scope.))}
            (tm.getToolboxFactory().hasTools(Scope.)) {
                ctx.addToolbox(tm.getToolboxFactory().createToolbox(Scope.))}
        }
        ctx}
}
私はもう一つのカスタムtoolboxの需要を増やしています.
しかし、ネットからコピーしたtoolbox.xmlをちゃんと貼りましたが、プロジェクトでは:
<toolbox>

    <!-- [ DateTool ]
         @see http://www.jajakarta.org/velocity/tools/velocity-tools-1.1/docs-ja/generic/DateTool.html  (ja)
        @see http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/DateTool.html  (en)
        @since VelocityTools 1.0
    -->
    <tool>
        <key>jsonUtils</key>
        <scope>application</scope>
        <class>org.*.JsonUtils</class>
    </tool>
</toolbox>
mvcはvmの展示にジャンプして、jsonUtilsを識別しません. 
いかんせん、追跡して入ります.
            ToolManager tm = ToolManager()
コードが発見されました.2.0のtoolboxの配置方式はもう別の形式に変えました.
velocity-tools.jar/org.apache.velocity.tools.geners.tools.xmlの中のフォーマットを参考にして、発見します.元々toolboxの定義方法が変わりました.
<?xml version="1.0" encoding="ISO-8859-1"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<tools>
   <toolbox scope="application">
       <tool class="com.*.utils.VelocityJsonUtils"/>
   </toolbox>
</tools>
toolsの構成を再定義すれば、機能は正常になります.
toolboxの名前については、注釈で書いてあります.
()
解決しました
問題のネット上での解決策が多いかもしれません.前のバージョンはどうやって問題を解決しますか?自分の問題に対して、心を静めて他の人のソースコードの実現を見にくる必要があります.すべてが明るくなりました.