1
2
3
4
5 package gboat2.base.plugin.struts.freemarker;
6
7 import java.net.URL;
8
9 import org.apache.struts2.ServletActionContext;
10
11 import com.opensymphony.xwork2.ActionInvocation;
12 import com.opensymphony.xwork2.util.ClassLoaderUtil;
13
14 import freemarker.cache.URLTemplateLoader;
15
16
17
18
19
20
21
22 public class GboatClassTemplateLoader extends URLTemplateLoader {
23
24 @Override
25 protected URL getURL(String name) {
26 ActionInvocation invocation = ServletActionContext.getContext().getActionInvocation();
27 Class<?> clazz = (invocation == null ? ServletActionContext.class : invocation.getAction().getClass());
28 URL url = ClassLoaderUtil.getResource(name, clazz);
29 return url;
30 }
31
32 }