Friday, July 24, 2026
HomeLanguagesJavaSpring MVC JSTL Configuration

Spring MVC JSTL Configuration

JavaServer Pages Tag Library (JSTL) is a set of tags that can be used for implementing some common operations such as looping, conditional formatting, and others. Here we will be discussing how to use the Maven build tool to add JSTL support to a Spring MVC application. also, you’ll learn how to activate JSTL tags in a Spring MVC application.

Step 1: JSTL maven dependencies

XML




<dependency>
  <groupid>javax.servlet</groupid>
  <artifactid>jstl</artifactid>
  <version>1.2</version>
  <scope>runtime</scope>
</dependency>
   
<dependency>
  <groupid>taglibs</groupid>
  <artifactid>standard</artifactid>
  <version>1.1.2</version>
  <scope>runtime</scope>
</dependency>


Step 2: To resolve JSTL views, use InternalResourceViewResolver.

2.1: Spring JSTL Java Configuration

// Annotation 
@Bean
// Method 
public ViewResolver configureViewResolver() 

{
  InternalResourceViewResolver viewResolve = new InternalResourceViewResolver();
  
  viewResolve.setPrefix("/WEB-INF/jsp/");
  viewResolve.setSuffix(".jsp");
  
  return viewResolve;
}

2.2: Spring JSTL XML Configuration

XML




<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
  <property name="prefix">
    <value>/WEB-INF/jsp/</value>
  </property>
  <property name="suffix">
    <value>.jsp</value>
  </property>
</bean>


Step 3: Use JSTL tags in JSP files

HTML




<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<h1>Welcome message : <c:out value="${message}"></c:out></h1>


RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6902 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6972 POSTS0 COMMENTS