Skip to Main Content
Spring MVC Beginner's Guide
book

Spring MVC Beginner's Guide

by Amuthan Ganeshan
June 2014
Beginner to intermediate content levelBeginner to intermediate
304 pages
7h 25m
English
Packt Publishing
Content preview from Spring MVC Beginner's Guide

Time for action – whitelisting form fields

In the previous exercise, while adding a new product, we bound every field of the Product domain in the form. However, it is meaningless to specify the unitsInOrder and discontinued values during the addition of a new product because nobody can make an order before adding the product to the store, and similarly, the discontinued products need not be added in our product list. So, we should not allow these fields to be bound to the form bean while adding a new product to our store. However, all the other fields of the Product domain object need to be bound. Let's see how to do this with the following steps:

  1. We open our ProductController class and add a method as follows:
    @InitBinder public void initialiseBinder(WebDataBinder ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Spring MVC Beginner's Guide - Second Edition

Spring MVC Beginner's Guide - Second Edition

Amuthan Ganeshan
Spring MVC: Designing Real-World Web Applications

Spring MVC: Designing Real-World Web Applications

Shameer Kunjumohamed, Hamidreza Sattari, Alex Bretet, Geoffroy Warin

Publisher Resources

ISBN: 9781783284870Supplemental Content