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 7748477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:47:43+00:00 2026-06-01T10:47:43+00:00

I’m new to Spring and trying to use the Spring Formatting SPI for UI

  • 0

I’m new to Spring and trying to use the Spring Formatting SPI for UI layer parsing and printing of values.

I’ve defined a custom formatter and have the parsing side working correctly and if I do a direct conversionService.convert(someObject, String.class) call then the value is converted (i.e. print()ed) correctly using the formatter I’ve defined.

However, in my template I’m only getting the object’s toString() representation displayed rather than the String from the registered conversionService.convert() call.

I’m using Mustache as the templating engine instead of Velocity or Freemarker (thank God). Is the Formatting SPI tied to JSP tags and/or do I need to extend the Mustache library I’m using to support Spring bind/form tags in order for this to work correctly?

I’ve scoured the documentation and searched all over and cannot find any information on this, but my apologies if my RTFM/Google skills are lacking.

  • 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-01T10:47:44+00:00Added an answer on June 1, 2026 at 10:47 am

    First of all, if you look at the pom.xml file for that Mustache Spring View library, it’s not using Mustache.java, it’s actually using Jmustache:

    https://github.com/sps/mustache-spring-view/blob/master/pom.xml

    <dependency>
        <groupId>com.samskivert</groupId>
        <artifactId>jmustache</artifactId>
        <version>${jmustache.version}</version>
    </dependency>
    

    You can find Jmustache here:

    https://github.com/samskivert/jmustache

    The view just passes your model as a Map<String, Object> to the Jmustache Template “execute()” method, so Spring is not involved anymore after that point. At that point it’s all about Jmustache figuring out how to generate output using your template syntax and your model values. The Jmustache code is a bit convoluted and hard to follow, but I think if you look at the “Template.Segment” subclasses defined in the Mustache class you will see where the Object values are getting turned to Strings using String.valueOf(Object) on line 568:

    https://github.com/samskivert/jmustache/blob/master/src/main/java/com/samskivert/mustache/Mustache.java

    String.valueOf(Object) just calls toString() on the Object passed in (if it’s not null):

    http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#valueOf%28java.lang.Object%29

    I think you’ve got two options. Handle all the String conversions yourself in your controller, before populating your model, and then make sure to populate your model only with String values. Or, you can try to extend or modify the Jmustache code to have it use Spring’s conversion API to handle the conversions to strings instead of using String.valueOf().

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.