Sunday, January 18, 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

1 COMMENT

Most Popular

Dominic
32474 POSTS0 COMMENTS
Milvus
118 POSTS0 COMMENTS
Nango Kala
6846 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12063 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7219 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6911 POSTS0 COMMENTS