Spring MVC Annotations Data validations:02

Vikas Taank
2 min readJul 28, 2024

Look at the previous reading here:

Lets look at some of the data validation Annotations:

The below os the Rest Controller for with the end point for the orders that get the current order.

package tacos.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;

import lombok.extern.slf4j.Slf4j;
import tacos.TacoOrder;

@Slf4j
@Controller
@RequestMapping("/orders")
@SessionAttributes("tacoOrder")
public class OrderController {

@GetMapping("/current")
public String orderForm() {
return "orderForm";
}

}

Let’s apply some of the Validation Rules on Data.

package tacos;
import java.util.List;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import…

--

--

Vikas Taank

I am new to Medium, trying to articulate my learnings so far . Please Join medium to read my articles. Please support- https://ko-fi.com/vikastaank