Hi,
I'm using spring 2.0 MVC. I use FreeMarker and its ftls for creating my htmls. also have view resolver and freemarkerTaglibFactory. I use these all cause i do have some JSP tags that are included in the ftls. Whenever i build ModelAndView Object are a return value of the spring controller i get the correct resut, and both ftl and JSP tags are generating my lovely htmls.
The problem took place when I tried to get the html as String. I neede it cause i want the html repersentation to be sent as an email using some service i have. Service works fine and I could get the html generated from ftl. Only one problem is that: the ftl couldn't resolve JSP tags. This doesn't contradict with what i've already said the ftl could resolve JSP tags. cause the first case (JSP is resolved in ftl) was when i return a ModelAndView object to the controller, but the second case (JSP is NOT resolved in ftl ) I was calling ftl this way:
Code:
public String printFTLtoString(Map dataModel, String templateName) {
Writer writer = null;
try{
writer = new StringWriter();
freemarker.template.Template template = getFreeMarkerConfigurer().getConfiguration().getTemplate(templateName);
template.process(dataModel, writer);
}catch(IOException ex){
throw new IllegalArgumentException("No template exists with name: "+templateName);
}catch(TemplateException ex){
throw new RuntimeException("Couldn't generate string using template:"+templateName, ex);
}
return writer.toString();
}The bean freeMarkerConfigurer is the bean we usually define in IOC container
The bean freeMarkerConfigurer is the bean we usually define in IOC container when we use FreeMarker. could some one tells me why it can't resolve jsp that way although it resolve it when i return a ModelAndView Object?
thanks in advance and I hope i stated my problem clearly!!