淘宝商城(天猫)高级技术专家.3年研发+3年性能测试调优/系统测试+4年团队管理与测试架构、研发系统实践. 新舞台新气象, 深化测试基础架构及研发架构,希望能在某个技术领域成为真正的技术大牛。欢迎荐才http://bbs.51testing.com/viewthread.php?tid=120496&extra=&page=1 .邮件: jianzhao.liangjz@alibaba-inc.com,MSN:liangjianzhao@163.com.微博:http://t.sina.com.cn/1674816524

Spring Velocity macro应用与调试

上一篇 / 下一篇  2008-09-26 22:24:00 / 个人分类:java性能监控与调优

默认情况下,velocity macro文件修改没有被应用服务器检测,必须重启才能生效。

 

 

Spring web.xml contextConfigLocation配置包含属性文件mvc-config.xml

 

<servlet>

<servlet-name>dispatcherServlet</servlet-name>     

<servlet-class> org.springframework.web.servlet.DispatcherServlet       </servlet-class>      

<init-param>          

<param-name>contextConfigLocation</param-name>         

<param-value>

/WEB-INF/mvc-config.xml

/WEB-INF/alert-config.xml

</param-value>   

</init-param>  

<load-on-startup>1</load-on-startup>  

 </servlet>

 

 

mvc-config.xml部分内容如下:

 

             <bean id="velocityConfigurer"                        class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">

             <property name="resourceLoaderPath">

            <value>WEB-INF/velocity/</value>  

             </property>

             <property name="velocityProperties">

                    <props>

                    <prop key="input.encoding">gb2312</prop>

                    <prop key="output.encoding">gb2312</prop>

                    <prop key="contentType">text/html;charset=gb2312</prop>

                    <prop key="file.resource.loader.cache">false</prop>

                    <prop key="file.resource.loader.modificationCheckInterval">1</prop>

                    <prop key="velocimacro.library.autoreload">true</prop>

                   <prop key="velocimacro.library">templates.vm</prop>

                    <prop key="runtime.log.logsystem.class">org.apache.velocity.runtime.log.SimpleLog4JLogSystem</prop>

                    <prop key="runtime.log">com.ali</prop>

                    <prop key="runtime.log.error.stacktrace">true</prop>

                    <prop key="runtime.log.warn.stacktrace">true</prop>

                    <prop key="runtime.log.info.stacktrace">false</prop>

                    <prop key="runtime.log.invalid.reference">true</prop>

            </props>

             </property>

 

      </bean>

      

       <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">

         <property name="suffix"><value>.vm</value></property>

                    <property name="exposeSpringMacroHelpers"><value>true</value></property>

                    <property name="exposeRequestAttributes"><value>true</value></property>

                    <property name="exposeSessionAttributes"><value>true</value></property>

                    <property name="contentType" value="text/html;charset=gb2312" />

                    <property name="dateToolAttribute">

     <value>dateTool</value>

         </property>

       </bean>

 

 

 

Velocity文件包括库文件templates.vm都放在WEB-INF/velocity/

确保velocity文件被修改都立即重新扫描,关键的参数:

<prop key="file.resource.loader.cache">false</prop>

                    <prop key="file.resource.loader.modificationCheckInterval">1</prop>

                    <prop key="velocimacro.library.autoreload">true</prop>

 

 

index.vm上通过:

#parse("templates.vm")引入velocity模版。


TAG: spring velocity macro 自动 reload java性能监控与调优

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar