Is there a way to get a view as String
already processed?
I need to send emails and I want to avoid creating the html views in a String
and better create a JSP view and be able to call it as a String
.
I've dealt with TemplateEngine
like this:
import org.springframework.restdocs.templates.Template;
import org.springframework.restdocs.templates.TemplateEngine;
@Service
public class LectorVistas
{
@Autowired
private TemplateEngine templateEngine;
public String obtenerVista(Model model, String vistaNombre) throws
IOException {
Template vista = templateEngine.compileTemplate(vistaNombre);
String view = vista.render(model.asMap());
return view;
}
}
But it generates an exception:
No qualifying bean of type [org.springframework.restdocs.templates.LectorVista] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependence
Is there a better way to do it? What is the error in my code?