<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
8.3.6 Using JSP Tag Libraries
Version: 3.2.3
8.3.6 Using JSP Tag Libraries
In addition to the simplified tag library mechanism provided by GSP, you can also use JSP tags from GSP. To do so simply declare the JSP to use with the taglib
directive:
Besides this you have to configure Grails to scan for the JSP tld files.
This is configured with the grails.gsp.tldScanPattern
setting. It accepts a comma separated String value. Spring’s PathMatchingResourcePatternResolver is used to resolve the patterns.
For example you could scan for all available tld files by adding this to application.groovy
:
grails.gsp.tldScanPattern='classpath*:/META-INF/*.tld,/WEB-INF/tld/*.tld'
JSTL standard library is no more added as a dependency by default. In case you are using JSTL, you should also add these dependencies to build.gradle
:
runtime 'javax.servlet:jstl:1.1.2'
runtime 'taglibs:standard:1.1.2'
Then you can use JSP tags like any other tag:
<fmt:formatNumber value="${10}" pattern=".00"/>
With the added bonus that you can invoke JSP tags like methods:
${fmt.formatNumber(value:10, pattern:".00")}