ftl中特殊关键字原样输出

在FreeMarker模板语言(FTL)中,${}用于变量替换,但若需输出该符号本身,可以使用${r"${dubbo.registry.address}"}的方式实现原样显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ftl中${}是关键字语法符号,但是要输出怎么办?没关系我们可以采用${r"${dubbo.registry.address}"}原样输出

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
	xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="
		     http://www.springframework.org/schema/beans
		     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
		     http://www.springframework.org/schema/tx
		     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
		     http://www.springframework.org/schema/aop
		     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
		     http://www.springframework.org/schema/context
		     http://www.springframework.org/schema/context/spring-context-3.0.xsd
		     http://www.springframework.org/schema/jee
		     http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
		     http://www.directwebremoting.org/schema/spring-dwr     
        	 http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd
        	 http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

	
	<dubbo:application name="module1" />
	<dubbo:registry address="${r"${dubbo.registry.address}"}"/>
	<dubbo:protocol name="dubbo" port="${r"${dubbo.protocol.port}"}"/>
	
	<import resource="dubbo-bussiness-config.xml"/>
	
</beans>


### Freemarker 模板引擎语法概述 FreeMarker模板语言(FTL)作为FreeMarker的核心组件,提供了丰富的语法规则来生成动态内容[^2]。以下是关于FreeMarker模板引擎的一些基本语法要素: #### 文本输出 最简单的操作就是直接放置纯文本,在模板中任何不被特殊标记包裹的文字都会按原样输出。 #### 变量插值 变量可以通过`${expression}`的形式插入到模板中的任意位置。表达式的求值结果会被转换成字符串并替换掉该占位符。 ```html <p>Hello ${user.name}!</p> ``` #### 控制结构 控制指令用于实现条件判断和循环逻辑等功能,采用`<#-- -->`形式书写注释以及`<#if>`, `<#else>`等关键字构建分支结构;通过`<#list>`完成迭代处理。 - **If/Else** 条件语句可以用来根据不同的情况显示不同内容 ```html <#if user.isAdmin()> Administrator Options... <#elseif user.isLoggedIn()> User Options... <#else> Guest Options... </#if> ``` - **List** 列表遍历可用于渲染集合数据项 ```html <ul> <#list users as user> <li>${user.fullName}</li> </#list> </ul> ``` #### 宏与函数定义 宏(`macro`)允许创建可重用的代码片段,而内联函数(`function`)则是返回计算后的值供其他地方调用。 ```html <#macro greet name="World"> Hello ${name}. </#macro> <@greet name="John"/> ``` #### 导入与其他高级特性 还可以导入外部文件、设置全局配置参数、捕获异常等多种强大功能等待探索。 更多详细的官方文档和教程建议查阅官方网站获取最新资料。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值