0
Velocity Template 개념을 사용하여 Java 파일을 생성해야합니다. 이걸 통해 안내해주십시오.Apache Velocity에서 템플릿을 정의하여 Java 코드를 생성 할 수 있습니까?
해야 몇 가지 방법, 수입 및 변수를 포함하는 자바 코드 ...
감사합니다, Easwar 속도/자바 부분
Velocity Template 개념을 사용하여 Java 파일을 생성해야합니다. 이걸 통해 안내해주십시오.Apache Velocity에서 템플릿을 정의하여 Java 코드를 생성 할 수 있습니까?
해야 몇 가지 방법, 수입 및 변수를 포함하는 자바 코드 ...
감사합니다, Easwar 속도/자바 부분
, 이것은 당신이해야 할 더 이하 :
을// factory and an engine instance
VelocityEngineFactory velocityEngineFactory = new VelocityEngineFactory();
VelocityEngine engine = velocityEngineFactory.createVelocityEngine();
// now you need to give the variables you wanna have access from velocity script
VelocityContext context = new VelocityContext(properties);
ByteArrayOutputStream temp = new ByteArrayOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(temp));
// generate the result, where scriptString is the velocity script
engine.evaluate(context, bufferedWriter, null, scriptString);
bufferedWriter.flush();
textResultant = temp.toString();
그래서 스크립트를 만들고로드하여 프로그래밍 방식으로 처리 할 수 있습니다.