Category: Spring MVC

What are Structured Outputs? Using Structured Outputs is an important aspect when interacting with LLMs programmatically. LLMs, by their nature, generate unstructured output. The unstructured output does not work well with programming languages which need structure to understand the data. Through prompting techniques, you can direct the LLM to create a structured output. The format […]Continue reading

A hidden feature of Spring AI is the support of String Templates, aka StringTemplates. StringTemplate is a lightweight Java template engine. It is simple, and easy to use. StringTemplate is a stable project, established in 2007 and now on its 4 major release. Here is an example from the homepage of the Stringtemplate website. On […]Continue reading

Spring Web applications and services need to process client requests sent over HTTP. When the HTTP clients send data with the request, the data is in the request body. On the application side, you need a mechanism to deserialize data sent in the request body to domain objects. This is done using the @RequestBody annotation. […]Continue reading

Data validation is a basic requirement for any application. This is more significant for web applications that accept data as input. Bean Validation or commonly known as JSR-380 is a Java standard that is used to perform validation in Java applications. To perform validation, data Items are applied constraints. As long as the data satisfies […]Continue reading

When you develop a Spring Bool RESTful service, you as a programmer are responsible for handling exceptions in the service. For instance, by properly handling exceptions, you can stop the disruption of the normal flow of the application. In addition, proper exception handling ensures that the code doesn’t break when an exception occurs. Another important […]Continue reading

Should I Use Spring REST Docs or OpenAPI? Recently, I was asked which is better to use. Spring REST Docs or OpenAPI. From the perspective of generating documentation for your APIs, you may think these two options are effectively the same thing. But, it’s not exactly an apples to apples comparison. These are significantly different […]Continue reading

When developing Spring Boot applications, you need to tell the Spring Framework where to look for Spring components. Using component scan is one method of asking Spring to detect Spring managed components. Spring needs the information to locate and register all the Spring components with the application context when the application starts. Spring can auto […]Continue reading

@RequestMapping is one of the most common annotation used in Spring Web applications. This annotation maps HTTP requests to handler methods of MVC and REST controllers. In this post, you’ll see how versatile the @RequestMapping annotation is when used to map Spring MVC controller methods. Request Mapping Basics In Spring MVC applications, the RequestDispatcher (Front Controller […]Continue reading