Velocity Templates - New Line

后端 未结 6 1200
醉话见心
醉话见心 2021-02-13 04:07

I\'ve been working with Apache\'s Velocity engine and a custom template.
The thing is, that I haven\'t been able to generate a String with the corresponding line breaks. I t

6条回答
  •  时光取名叫无心
    2021-02-13 04:57

    We had issues with newlines and ended up putting a property on the VelocityContext:

    VelocityContext ctx = new VelocityContext();
    ctx.put("newline", "\n");
    

    Then, wherever we needed to use a newline, we would reference the context variable:

    $newline
    

    We use this in cases where we need to replace newlines in a string with
    .

提交回复
热议问题