Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:37:17+00:00 2026-06-14T22:37:17+00:00

I am reading the Thymeleaf + Spring 3 Tutorial and also trying to build

  • 0

I am reading the Thymeleaf + Spring 3 Tutorial and also trying to build a modular application. My goal is to be able to load thymeleaf templates from Jars in the classpath.

For this I have configured a SpringTemplateEngine in the next xml:

<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
    <property name="templateResolvers">
        <util:set>
            <ref bean="servletContextTemplateResolver" />
            <ref bean="classpathPluginTemplateResolver" />
        </util:set>
    </property>
</bean>

<bean id="classpathPluginTemplateResolver"
    class="org.mael.codex.arcana.web.thymeleaf.templates.ClasspathPluginTemplateResolver">
    <property name="prefix" value="/META-INF/codexarcana/plugin/views" />
    <property name="suffix" value=".html" />
    <property name="templateMode" value="HTML5" />
</bean>

And the ClasspathPluginTemplateResolver code:

public class ClasspathPluginTemplateResolver extends TemplateResolver {

public ClasspathPluginTemplateResolver() {
    super();
    super.setResourceResolver(new ClasspathTemplateResolver());
}

@Override
public void setResourceResolver(IResourceResolver resourceResolver) {
    throw new ConfigurationException("Cannot set a resource resolver on "
            + this.getClass().getName() + ". If "
            + "you want to set your own resource resolver, use "
            + TemplateResolver.class.getName() + "instead");
}
}

And the ClasspathTemplateResolver:

public class ClasspathTemplateResolver implements IResourceResolver {

@Override
public String getName() {
    return this.getClass().getSimpleName();
}

@Override
public InputStream getResourceAsStream(
        TemplateProcessingParameters templateProcessingParameters,
        String resourceName) {

    if (resourceName == null || resourceName.isEmpty()) {
        throw new IllegalArgumentException("Resource name cannot be null");
    }

    try {
        return new ClassPathResource(resourceName).getInputStream();
    } catch (IOException e) {
        throw new RuntimeException("Cannot open resource '" + resourceName
                + "'", e);
    }
}

}

How can I avoid name conflicts in the templates resolved by the ClasspathPluginTemplateResolver?

Example:

Let’s suppose I have 2 plugins with this directory structure:

codexarcana-poll-plugin.jar
    ----/META-INF/codexarcana/plugin/views/wizard.html

and

codexarcana-gravatar-plugin.jar
    ----/META-INF/codexarcana/plugin/views/wizard.html

In this case I believe that the ClasspathTemplateResolver will return a wrong view or will have conflicts resolving such thing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:37:19+00:00Added an answer on June 14, 2026 at 10:37 pm

    Implementations of the ITemplateResolver interface that extend the base org.thymeleaf.templateresolver.AbstractTemplateResolver class (like all out-of-the-box implementations do) have a resolvablePatterns property that allows you to specify a series of patterns that will be applied for determining which views will be considered resolvable by that specific template engine. This should help you avoid collisions.

    There you can specify wildcarded patterns like admin/*, user/*/create, etc.

    Have in mind that these patterns apply on the view name, and not on the template file name itself. For example, if your template is /WEB-INF/templates/index.html and your view resolver adds prefix /WEB-INF/templates/ and suffix .html, your view name is index, and so a resolvable pattern like *.html would never match.

    Also, there is an order property that establishes the order in which template resolvers will be asked to resolve a view.

    Disclaimer, as required by StackOverflow rules: I’m the author of Thymeleaf.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

reading this https://developers.google.com/in-app-payments/docs/tutorial Quoted from the above page: Because you sign the JWT using
Reading the docs, I'd expect $(#wrap2).remove(.error) to remove all .error elements from #wrap2 .
Reading the MCIMX50 Application Processor Reference Manuals on page 1368 (Section 33.3) there is
Reading or writing a C code, I often have difficulties translating the numbers from
Reading the documentation on the changes to UIViewControllers in iOS, I trying to figure
Reading the design guidelines. I came across a little issue while trying to practice
Reading through wikipedia I came across the concept of Sprints in Agile development. From
Reading code from other posts, I'm seeing something like this. struct Foo { Foo()
Reading the Python 3.2 tutorial here , towards the end one of the examples
Reading MSDN, float ranges from 1E-45 to 1E38, double ranges from 1E-324 to 1E308,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.