Groovy 简单应用

import groovy.lang.Binding;
import groovy.lang.GroovyShell;

	protected GroovyShell createGroovyShell(GenerateDTO dto){
		Binding binding = new Binding();
		GroovyShell shell = new GroovyShell(binding);
		binding.setVariable("入参年", dto.getYear());
		binding.setVariable("入参月", dto.getPeriod());
		return shell;
	}

createGroovyShell(dto).evaluate(your expression)

猜你喜欢

转载自wzwd111.iteye.com/blog/1130684