2

I have a variable in JSP tag file as below

<span class="breadcrumbName">${breadcrumb.name}</span>

I need to convert the text/string from this variable into Title Case ... Can someone please help me with this? Thanks

Hello Universe
  • 3,248
  • 7
  • 50
  • 86

2 Answers2

1

Solved by using the following

${fn:toUpperCase(fn:substring(breadcrumb.name, 0, 1))}${fn:toLowerCase(fn:substring(breadcrumb.name, 1, -1))}   

make sure you have the following

<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
Hello Universe
  • 3,248
  • 7
  • 50
  • 86
-2

I dont think so you can convert the string's case in el, I may be wrong

You can use css to find a workaround by applying proper styling to your span tag

<span style="text-transform: capitalize;"
 class="breadcrumbName">${breadcrumb.name}</span>

Hope this helps.

Meherzad
  • 8,433
  • 1
  • 30
  • 40
  • 1
    That will only make it capitalize.. I need title case. So if breadcrumb text is "my life". I want "My Life" and not "My life" – Hello Universe Feb 22 '13 at 15:47
  • Finally Solved it as follows ${fn:toLowerCase(breadcrumb.name)} Using css turn the text to capitalize.. – Hello Universe Feb 23 '13 at 08:33
  • 1
    If you don't want to rely on CSS, you could always do as per this answer — http://stackoverflow.com/a/482959/1474421 & use WordUtils in a custom taglib. – anotherdave Feb 23 '13 at 18:54