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 – adding Spring validation

If you have a constraint that doesn't allow anyone to add more than 99 units of any product if the unit price is greater than 1000 USD for that product, add such a validation using Spring validation in the project. Perform the following steps:

  1. Create a class called UnitsInStockValidator under the com.packt.webstore.validator package in the source folder src/main/java. Add the following code into it:
    package com.packt.webstore.validator;
    
    import java.math.BigDecimal;
    import org.springframework.stereotype.Component;
    import org.springframework.validation.Errors;
    import org.springframework.validation.Validator;
    import com.packt.webstore.domain.Product;
    
    @Component
    public class UnitsInStockValidator implements ...
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