Monty Swanson
Monty Swanson

Reputation: 795

How to print Spring MVC model values in a JSP Page

I have a jsp file that receives data from a Spring MVC Controller

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>
<%@ page session="false"%> 

<form:form action="" commandName="someDetail">
<form:input path="name" class="form-control" />
<form:input path="address" class="form-control" />

This successfully displays the data inside a textbox. I want to display the data as an ordinary text without the textbox. I have tried printing it as

${address}

but it does not work. How do I print the values without the textbox?

Upvotes: 0

Views: 2513

Answers (1)

Romain Warnan
Romain Warnan

Reputation: 1042

As there is a commandName="someDetail", I assume there is an object called someDetail in the model.

If so, you just have to write ${someDetail.address} to print the address in the generated html.

Upvotes: 1

Related Questions