
系列文章目录提示这里可以添加系列文章的所有文章的目录目录需要自己手动添加例如第一章 Python 机器学习入门之pandas的使用提示写完文章后目录可以自动生成如何生成可参考右边的帮助文档文章目录系列文章目录前言一、velocity二、使用步骤1.引入库2.veiw总结前言提示这里可以添加本文要记录的大概内容例如随着人工智能的不断发展机器学习这门技术也越来越重要很多人都开启了学习机器学习本文就介绍了机器学习的基础内容。提示以下是本篇文章正文内容下面案例可供参考一、velocity示例pandas 是基于NumPy 的一种工具该工具是为了解决数据分析任务而创建的。二、使用步骤1.引入库代码如下示例dependency groupIdcom.shield-solutions/groupId artifactIdspring-velocity-adapter/artifactId version1.0.0.RELEASE/version /dependencypackage cn.ucm.rubik.common.appconfig;import com.shieldsolutions.velocity.view.VelocityConfigurer;import com.shieldsolutions.velocity.view.VelocityViewResolver;import org.springframework.beans.factory.annotation.Value;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.ViewResolver;import java.util.Properties;/** * Created by ucmed on 2018/01/08. */Configuration public class VelocityConfig{publicstaticfinal String INPUT_ENCODEinput.encoding;publicstaticfinal String OUTPUT_ENCODINGoutput.encoding;publicstaticfinal String CHARSET_UTFUTF-8;publicstaticfinal String CONTENT_TYPEtext/html;charsetUTF-8;publicstaticfinal String TOOL_BOX_CONFIG_LOCATIONWEB-INF/toolbox.xml;Value(${velocity.prefer.file.system.access})private Boolean fileSystemAccess;Value(${velocity.resource.loader.path})private String loaderPath;Value(${velocity.resource.loader.cache})private Boolean loaderCache;/** * bean idviewResolver * classorg.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver * property namecache valuefalse/ * property nameprefix value/ * property namesuffix value.vm/ * property nameviewClass * valuecom.ucmed.common.velocity.VelocityLayoutToolboxView/ * property namecontentType valuetext/html;charsetUTF-8/ * property nametoolboxConfigLocation valueWEB-INF/toolbox.xml/ * /bean * return */Bean public ViewResolverviewResolver(){VelocityViewResolver viewResolvernewVelocityViewResolver();viewResolver.setCache(loaderCache);viewResolver.setPrefix();viewResolver.setSuffix(.vm);viewResolver.setViewClass(com.ucmed.common.velocity.VelocityLayoutToolboxView.class);viewResolver.setContentType(CONTENT_TYPE);viewResolver.setToolboxConfigLocation(TOOL_BOX_CONFIG_LOCATION);returnviewResolver;}/** * bean idvelocityConfigurer * classorg.springframework.web.servlet.view.velocity.VelocityConfigurer * property namepreferFileSystemAccess value${velocity.prefer.file.system.access}/ * property nameresourceLoaderPath value${velocity.resource.loader.path}/ * property namevelocityProperties * props * prop keyinput.encodingUTF-8/prop * prop keyoutput.encodingUTF-8/prop * /props * /property * /bean * return */Bean public VelocityConfigurervelocityConfigurer(){VelocityConfigurer vcnewVelocityConfigurer();vc.setResourceLoaderPath(loaderPath);vc.setPreferFileSystemAccess(fileSystemAccess);Properties pnewProperties();p.setProperty(INPUT_ENCODE,CHARSET_UTF);p.setProperty(OUTPUT_ENCODING,CHARSET_UTF);vc.setVelocityProperties(p);returnvc;}}2.veiw代码如下示例package com.ucmed.common.velocity; import com.shieldsolutions.velocity.view.VelocityLayoutView; import org.apache.velocity.context.Context; import org.apache.velocity.tools.Scope; import org.apache.velocity.tools.ToolManager; import org.apache.velocity.tools.view.ViewToolContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Map; /** * Spring3默认的 createVelocityContext 方法中采用的是 tools-1.x 的 ToolboxManager, * ServletToolboxManager等类 加载toolbox但是 tools 2.x 中已经废弃了这些类导致了无法加载tools 2.x。 * 所以这里采用tools 2.x中新的 ToolManager方式重写此方法加载toolbox2.x。 */ public class VelocityLayoutToolboxView extends VelocityLayoutView { Override protected Context createVelocityContext(MapString, Object model, HttpServletRequest request, HttpServletResponse response) throws Exception { ViewToolContext ctx new ViewToolContext(this.getVelocityEngine(), request, response, this.getServletContext()); if(this.getToolboxConfigLocation() ! null) { ToolManager tm new ToolManager(); tm.setVelocityEngine(this.getVelocityEngine()); tm.configure(this.getServletContext().getRealPath( this.getToolboxConfigLocation())); for(String scope : Scope.values()) { ctx.addToolbox(tm.getToolboxFactory().createToolbox(scope)); } } if(model ! null !model.isEmpty()) { ctx.putAll(model); } return ctx; } }总结提示这里对文章进行总结例如以上就是今天要讲的内容本文仅仅简单介绍了pandas的使用而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。