zoukankan      html  css  js  c++  java
  • Velocity模板引擎下 velocity.properties转义(转码)配置

    velocity配置文件中的编码配置类:

    //对html文件编码的配置
    org.apache.velocity.app.event.implement.EscapeHtmlReference
    //对javascript文件编码的配置
    org.apache.velocity.app.event.implement.EscapeJavascriptReference
    //对sql文件编码的配置
    org.apache.velocity.app.event.implement.EscapeSqlReference
    //对xml文件编码的配置
    org.apache.velocity.app.event.implement.EscapeXmlReference

    1:在velocity.properties中配置全局变量转义:


    default.contentType=text/html; charset=UTF-8
    input.encoding=UTF-8
    output.encoding=UTF-8
    eventhandler.referenceinsertion.class = org.apache.velocity.app.event.implement.EscapeHtmlReference
    eventhandler.referenceinsertion.class = org.apache.velocity.app.event.implement.EscapeSqlReference
    eventhandler.escape.html.match = /msg.*/
    eventhandler.escape.sql.match = /sql.*/



    2:在velocity.properties中配置局部变量转义:

    default.contentType=text/html; charset=UTF-8
    input.encoding=UTF-8
    output.encoding=UTF-8
    eventhandler.referenceinsertion.class = org.apache.velocity.app.event.implement.EscapeHtmlReference
    eventhandler.referenceinsertion.class = org.apache.velocity.app.event.implement.EscapeSqlReference
    eventhandler.escape.html.match = /_html_*/
    eventhandler.escape.sql.match = /_sql_*/

    前台数据显示时 要转义的数据变量名定义需遵循:


    格式:_html_自定义名字

    例如:_html_title、_html_userName等等


  • 相关阅读:
    RabbitMq使用说明
    php使用rabbitmq需安装amqp拓展协议
    新建springboot web项目pom报错
    HttpRunner Manager 接口自动化平台搭建
    数据库存储过程进行批量插入数据
    Windows系统下Robot Framework的安装
    利用Charles模拟客户端弱网环境进行弱网测试
    JMeter进行简单的接口压测
    JMeter的安装和使用
    grep, sed 和 awk 学习总结
  • 原文地址:https://www.cnblogs.com/cuker919/p/4878543.html
Copyright © 2011-2022 走看看