So, I see all answer this problem in Stackoverflow, but not be of any help to me. ( SpringMVC+Thymeleaf ,error message is : template might not exist or might not be accessible by any of the configured Template Resolvers
Error resolving template "pages", template might not exist or might not be accessible by any of the configured Template Resolvers
SpringMVC+Thymeleaf ,error message is : template might not exist or might not be accessible by any of the configured Template Resolvers
... )
Here my servlet-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<!-- Basic Configurations -->
<context:annotation-config/>
<context:component-scan base-package="com.podium.italia.controller"/>
<context:component-scan base-package="com.podium.italia.service"/>
<context:component-scan base-package="com.podium.italia.model"/>
<context:component-scan base-package="com.podium.italia.repository"/>
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<!-- i18n -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="WEB-INF/i18n"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="useCodeAsDefaultMessage" value="true"/>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
<property name="defaultLocale" value="en"/>
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
</bean>
<!-- Email support -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.gmail.com" />
<property name="port" value="587" />
<property name="protocol" value="smtp" />
<property name="username" value="[email protected]" />
<property name="password" value="Style@mix2014" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.smtp.quitwait">true</prop>
</props>
</property>
</bean>
<!-- THYMELEAF: Template Resolver for email templates -->
<bean id="emailTemplateResolver" class="org.thymeleaf.templateresolver.ClassLoaderTemplateResolver">
<property name="prefix" value="mail/" />
<property name="templateMode" value="HTML5" />
<property name="characterEncoding" value="UTF-8" />
<property name="order" value="1" />
</bean>
<!-- THYMELEAF: Template Resolver for webapp pages -->
<!-- (we would not need this if our app was not web) -->
<bean id="webTemplateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="templateMode" value="HTML5" />
<property name="characterEncoding" value="UTF-8" />
<property name="order" value="2" />
</bean>
<!-- THYMELEAF: Template Engine (Spring3-specific version) -->
<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolvers">
<set>
<ref bean="emailTemplateResolver" />
<ref bean="webTemplateResolver" />
</set>
</property>
</bean>
<!-- THYMELEAF: View Resolver - implementation of Spring's ViewResolver interface -->
<!-- (we would not need this if our app was not web) -->
<bean id="viewResolver" class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
<property name="characterEncoding" value="UTF-8" />
</bean>
<import resource="daoContext.xml"/>
Here emailService:
final WebContext ctx = new WebContext(request,response, request.getServletContext(), locale);
//.....
// Create the HTML body using Thymeleaf
final String htmlContent = this.templateEngine.process("email-inlineimage.html", ctx);
message.setText(htmlContent, true /* isHtml */);
And Error:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "email-
inlineimage.html", template might not exist or might not be accessible by any of the
configured Template Resolvers
org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:245)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:924)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:898)
com.podium.italia.service.EmailService.sendMailWithInlineImages(EmailService.java:112)
I can't spot error in your servlet-context.xml so problem must be buried somewhere else (are you sure you have template file on classpath exactly at mail/email-inlineimage.html?). I'm providing working example as whole project (since it's overkill to paste everything to code samples here) which you can import to STS and run.
Spring Thymeleaf Mailing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With