>  기사  >  백엔드 개발  >  속도의 11번째 응용예---널 처리

속도의 11번째 응용예---널 처리

黄舟
黄舟원래의
2017-01-17 11:07:391193검색

처리를 하지 않으면 그대로 출력됩니다
$title

이것은 우리가 예상한 것과 다릅니다

빈 문자열을 출력하고 싶기 때문에 이렇게 해야 합니다. this: $!title

// 2Create a Context object
VelocityContextcontext = new VelocityContext();
// 3 Addyou data object to this context
context.put("title",null);
// 4Choose a template
Templatetemplate = Velocity.getTemplate("null.vm");
// 5Merge the template and you data to produce the output
StringWritersw = new StringWriter();
BufferedWriterbufferWriter = new BufferedWriter(sw);
template.merge(context,bufferWriter);
bufferWriter.flush();
System.out.println(sw.toString());
null.vm
$title
=====
$!title

위는 Velocity---null 처리 내용의 11번째 적용 예시입니다. 더 많은 관련 내용은 PHP 중국어 홈페이지(www. php.cn)!


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.