Introduction to the Spring Framework:
Generar description
IoC container
Dependency Injection
Beans scope and lifecycle
Autowiring
XML and annotation based configuration
Additional features
Spring MVC 3.0 Framework
Objective:
1. Introduce Spring MVC Module
2. Learn about Spring MVC Components (Dispatcher, Handler mapping, Controller, View Resolver, View)
Slides:
1. What Is Spring?
2. Why use Spring?
3. By the way, just what is MVC?
4. MVC Architecture
5. Spring MVC Architecture
7. Spring MVC Components
8. DispatcherServlet
9. DispatcherServlet Architecture.........
.........................................................
University of Colorado PhD software engineering student Aaron Schram explains the details of creating a web applications using the Spring MVC framework
This is a basic tutorial on Spring core.
Best viewed when animations and transitions are supported, e.g., view in MS Powerpoint. So, please try to view it with animation else the main purpose of this presentation will be defeated.
Presentation explain about
Spring Boot vs Spring vs Spring MVC,
Advantages,
Where to start and how does Spring boot work ?,
Dependency Management,
Logging,
Exception Handling,
Database Handling.
in Spring boot.
Overview of Spring Boot for the rapid development of Java Applications and Microservices. More information can be found at : https://www.spiraltrain.nl/course-spring-boot-development/?lang=en
Introduction to the Spring Framework:
Generar description
IoC container
Dependency Injection
Beans scope and lifecycle
Autowiring
XML and annotation based configuration
Additional features
Spring MVC 3.0 Framework
Objective:
1. Introduce Spring MVC Module
2. Learn about Spring MVC Components (Dispatcher, Handler mapping, Controller, View Resolver, View)
Slides:
1. What Is Spring?
2. Why use Spring?
3. By the way, just what is MVC?
4. MVC Architecture
5. Spring MVC Architecture
7. Spring MVC Components
8. DispatcherServlet
9. DispatcherServlet Architecture.........
.........................................................
University of Colorado PhD software engineering student Aaron Schram explains the details of creating a web applications using the Spring MVC framework
This is a basic tutorial on Spring core.
Best viewed when animations and transitions are supported, e.g., view in MS Powerpoint. So, please try to view it with animation else the main purpose of this presentation will be defeated.
Presentation explain about
Spring Boot vs Spring vs Spring MVC,
Advantages,
Where to start and how does Spring boot work ?,
Dependency Management,
Logging,
Exception Handling,
Database Handling.
in Spring boot.
Overview of Spring Boot for the rapid development of Java Applications and Microservices. More information can be found at : https://www.spiraltrain.nl/course-spring-boot-development/?lang=en
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
This talk introduces Spring's REST stack - Spring MVC, Spring HATEOAS, Spring Data REST, Spring Security OAuth and Spring Social - while refining an API to move higher up the Richardson maturity model
Spring Data is a high level SpringSource project whose purpose is to unify and ease the access to different kinds of persistence stores, both relational database systems and NoSQL data stores.
This ppt provide basic understanding regarding Spring Boot. And how to configure Spring Boot application with Hibernate and mysql by using eclipse IDE. Also provides understanding about how to configure Spring Tool Suit (STS) in Eclipse.
This presentation is about Spring MVC. Topics covered in this session are:
1. HTTP Servlet
2. What is Spring MVC?
3. MVC Architecture
4. Request Processing Workflow in Spring MVC
5. Spring Web Application Context
6. Spring MVC Configuration
7. Important Annotations
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
Course Description
#springframework, #spring, #udemy, #discount, #programming, #springmvc, spring, #udemycourse, #education
NEW udemy course related to the latest Java Spring MVC Framework 4 for developing WEB applications with popular and proven technologies such as AngularJS by Google and HTML5. (Lectures are divided in three main sections so you don't have to learn AngularJS Framework until you start the last section. The last section will teach you AngularJS by Google and the integration with Java Spring MVC Framework 4)
https://www.udemy.com/java-spring-mvc-framework-with-angularjs-by-google-and-html5
Moreover, this course is designed and created with the mindset of teaching you the latest web technologies in a short period of time with low training cost and high-quality content including real production quality code examples.
Therefore after attending this course, you will be ready to design and develop any commercial Java Spring MVC applications by learning the main principals, best practices, and most important concepts.
Furthermore, this is a fast track course and covers the most important concepts in AngularJS Framework, HTML5 and the latest Java Spring MVC Framework 4x with code examples and sample applications. You will be able to download source codes/slides/diagrams by attending this course and you can use those samples/codes in your applications as well. Therefore, it will be more than enough for you to develop Java Spring MVC applications if you attend this course.
The benefits of attending this udemy course are listed like as below;
You will earn a higher salary hence you will be able to use the latest and productive technologies and this course will also improve the way of your thinking in terms of programming by teaching you dependency injection principle used in Spring MVC and AngularJS
You will be more confident about commercial WEB programming for the following years and general programming concepts as well.
We will only use FREE Open Source Software tools during the development of components in this course.
You will learn the latest Java Spring MVC Framework with hands-on examples
You will learn the usage of AngularJS by Google for developing structured rich client side applications
You will understand the usage of latest useful basic HTML5 tags with code examples
You will gain experience of using CSS(Style Sheets) in web applications
Learn how to develop, test, run and debug Java Spring MVC applications
Learn how to integrate AngularJS with Java Spring MVC framework.
https://www.udemy.com/java-spring-mvc-framework-with-angularjs-by-google-and-html5
#springframework, #spring, #udemy, #discount, #programming, #springmvc, spring, #udemycourse, #education
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
This talk introduces Spring's REST stack - Spring MVC, Spring HATEOAS, Spring Data REST, Spring Security OAuth and Spring Social - while refining an API to move higher up the Richardson maturity model
Spring Data is a high level SpringSource project whose purpose is to unify and ease the access to different kinds of persistence stores, both relational database systems and NoSQL data stores.
This ppt provide basic understanding regarding Spring Boot. And how to configure Spring Boot application with Hibernate and mysql by using eclipse IDE. Also provides understanding about how to configure Spring Tool Suit (STS) in Eclipse.
This presentation is about Spring MVC. Topics covered in this session are:
1. HTTP Servlet
2. What is Spring MVC?
3. MVC Architecture
4. Request Processing Workflow in Spring MVC
5. Spring Web Application Context
6. Spring MVC Configuration
7. Important Annotations
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
Course Description
#springframework, #spring, #udemy, #discount, #programming, #springmvc, spring, #udemycourse, #education
NEW udemy course related to the latest Java Spring MVC Framework 4 for developing WEB applications with popular and proven technologies such as AngularJS by Google and HTML5. (Lectures are divided in three main sections so you don't have to learn AngularJS Framework until you start the last section. The last section will teach you AngularJS by Google and the integration with Java Spring MVC Framework 4)
https://www.udemy.com/java-spring-mvc-framework-with-angularjs-by-google-and-html5
Moreover, this course is designed and created with the mindset of teaching you the latest web technologies in a short period of time with low training cost and high-quality content including real production quality code examples.
Therefore after attending this course, you will be ready to design and develop any commercial Java Spring MVC applications by learning the main principals, best practices, and most important concepts.
Furthermore, this is a fast track course and covers the most important concepts in AngularJS Framework, HTML5 and the latest Java Spring MVC Framework 4x with code examples and sample applications. You will be able to download source codes/slides/diagrams by attending this course and you can use those samples/codes in your applications as well. Therefore, it will be more than enough for you to develop Java Spring MVC applications if you attend this course.
The benefits of attending this udemy course are listed like as below;
You will earn a higher salary hence you will be able to use the latest and productive technologies and this course will also improve the way of your thinking in terms of programming by teaching you dependency injection principle used in Spring MVC and AngularJS
You will be more confident about commercial WEB programming for the following years and general programming concepts as well.
We will only use FREE Open Source Software tools during the development of components in this course.
You will learn the latest Java Spring MVC Framework with hands-on examples
You will learn the usage of AngularJS by Google for developing structured rich client side applications
You will understand the usage of latest useful basic HTML5 tags with code examples
You will gain experience of using CSS(Style Sheets) in web applications
Learn how to develop, test, run and debug Java Spring MVC applications
Learn how to integrate AngularJS with Java Spring MVC framework.
https://www.udemy.com/java-spring-mvc-framework-with-angularjs-by-google-and-html5
#springframework, #spring, #udemy, #discount, #programming, #springmvc, spring, #udemycourse, #education
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsRaghavan Mohan
Organizations are increasingly communicating between disparate
software components in a loosely coupled and often asynchronous manner. These tutorials
will help you understand two of the popular integration technologies Web Services &
messaging (i.e. JMS – Java Messaging Service).
This is a presentation on Spring 3 annotations on a web stack. It includes basic spring annotation details, working with jpa, and the new MVC stuff. The code samples add a lot. I'll try to get them up on github.com.
This presentation will guide you through the MVC Pattern and Flex implementation of MVC (Cairgorm and Mate Frameworks)
http://blog.go4flash.com/articles/flex-articles/mvc-pattern-presentation-cairngorm-vs-mate/
Building RESTful applications using Spring MVCIndicThreads
REST is an alternate and simpler approach for implementing WebServices. It is based on the HTTP protocol and hence leverages a lot of existing infrastructures. It uses an uniform interface thus making it easy to build client applications. In this session we will look at the fundamental concepts behind REST (Resource, URI, Stateless Conversation ..) and how to apply it in the context of a real applcation. We will also discuss the pros & cons of RESTful vs Soap based webservices. We will discuss the design of RESTful application and then look at how to implement it using Spring MVC.
The easy way to develop Java applications has always been the standard stack (Spring, JEE, SQL) that confirms the LAMP equivalent in Java-speak. This presentation compares this model with a real use case based on Guice, Jersey and AppEngine.
SOAP Web Services have a well established role in the enterprise, but aside from the many benefits of the WS-* standards, SOAP and XML also carry additional baggage for developers. Consequently, REST Web Services are gaining tremendous popularity within the developer community. This session will begin by comparing and contrasting the basic concepts of both SOAP and REST Web Services. Building on that foundation, Sam Brannen will show attendees how to implement SOAP-based applications using Spring-WS 2.0. He will then demonstrate how to build a similar REST-ful application using Spring MVC 3.0. The session will conclude with an in-depth look at both server-side and client-side development as well as efficient integration testing of Web Services using the Spring Framework.
Today's applications don't live in a vacuum - you need to take the applications to where your users are. Let Spring's REST support along with its powerful client-side technology support, help you get there faster.
Применение паттерна Page Object для автоматизации веб сервисовCOMAQA.BY
Доклад о том, как еще можно организовать автоматизацию тестирования веб-сервисов, а именно, приспособить подход/шаблон Page Object (казалось бы, причем тут он?). Главное достоинство подхода - его максимальная простота и дружелюбность. Мы рассмотрим живой и успешно работающий на реальном проекте фреймворк, построенный подобным образом, разберём на слои, обсудим плюсы, минусы и саму идею подхода в целом.
Apache Wicket is constantly growing in popularity throughout all kinds of projects. However Wicket doesn't come out of the box with a built-in Java EE support. Integration to CDI is missing and the same is valid for Bean Validation support for example. This session demonstrates how you can user CDI, Conversations and Bean Validation together with Apache Wicket. The first part of the talk will consist of a small slide-driven theoretical part whereas the second part will consist of a coding session that demonstrates hands-on how to hook everything together.
This presentation gives a high level concepts and more of code to take a stab at developing a simple Restful server. I targeted people who would like to build a simple RESTFul server from scratch and experiment.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
5. Spring MVC – Advanced topics
Annotation driven controllers
@Controller
» Spring stereotype that identify a class as being a Spring
Bean.
» Has an optional ‘value’ property.
// Bean name is ‘loginController’
@Controller
public class LoginController {
}
// Bean name is ‘portal’.
@Controller(‚portal‛)
public class PortalController {
}
6. Spring MVC – Advanced topics
Annotation driven controllers
@RequestMapping
» Define URL mapping for a class and/or method.
// Controller root URL: http://host.com/portal
@Controller
@RequestMapping(‚/portal‛)
public class PortalController {
// Handle [GET] http://host.com/portal
@RequestMapping(method = RequestMethod.GET)
public String enterPortal() { ... }
// Handle [GET] http://host.com/portal/userProfile
@RequestMapping(‚/userProfile‛)
public String processUserProfileRequest() { ... }
}
» Support deterministic and Ant-style mapping
7. Spring MVC – Advanced topics
Annotation driven controllers
@RequestMapping
» Available properties:
method – List of supported HTTP method (GET, POST, ...).
produces/consumes – define expected content types.
GET http://google.com/ HTTP/1.1
Accept: text/html, application/xhtml+xml, */* HTTP
Accept-Language: he-IL request
Accept-Encoding: gzip, deflate
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8 HTTP
Date: Sun, 29 Jan 2012 19:45:21 GMT response
Expires: Tue, 28 Feb 2012 19:45:21 GMT
8. Spring MVC – Advanced topics
Annotation driven controllers
@RequestMapping
@Controller
@RequestMapping(‚/portal‛)
public class UserInfoController {
@RequestMapping(value = ‚/userInfo/xml‚,
consumes = ‚application/json‛,
produces = ‚application/xml‛)
public UserInformation getUserInformationAsXML() { Requires message
}
converters
@RequestMapping(value = ‚/userInfo/yaml‚,
consumes = ‚application/json‛,
produces = ‚application/Json‛)
public UserInformation getUserInformationAsJSon() {
}
}
9. Spring MVC – Advanced topics
Annotation driven controllers
@RequestMapping
» Required parameters.
// URL must in a form of: http://host.com/?userId=...&username=admin
@RequestMapping(value = ‚/‚, params = { ‚userId‛, ‚username!=guest‛, ‚!password‛ })
public UserInformation getUserInformationAsXML() {
}
» Required headers
@RequestMapping(value = ‚/userInfo‚, headers = { ‚Accept-Language=he-IL‛ })
public UserInformation getUserInformationAsXML() {
} GET http://google.com/ HTTP/1.1
Accept-Language: he-IL
Accept-Encoding: gzip, deflate
10. Spring MVC – Advanced topics
Annotation driven controllers
URI templates (@PathVariable)
» Allow us to define part of the URI as a template token.
» Support regular expressions to narrow scope of values.
» Only for simple types, java.lang.String or Date variant.
» Throw TypeMismatchException on failure to convert.
// Handle ‘userId’ with positive numbers only (0 or greater).
@RequestMapping(‚/users/{userId:[0-9]+})
public void processUserRequest(@PathVariable(‚userId‛) int userId) { ... }
// Handle ‘userId’ with negative numbers only.
@RequestMapping(‚/users/{userId:-[0-9]+})
public void processUserRequest(@PathVariable(‚userId‛) int userId) { ... }
11. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Define a new model attribute.
Single attribute approach
Multiple attributes approach
» Access existing model attribute.
12. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Definition of a single model attribute
@Controller
public class PrepareFormController
@Override
public ModelAndView prepareForm() {
ModelAndView mav = new ModelAndView("details");
mav.addObject("userDetails", new UserDetails());
mav.addObject("months", createIntegerList(1, 12));
mav.addObject("years", createIntegerList(1940, 2011));
return mav;
}
}
13. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Definition of a single model attribute
@Controller
public class PrepareFormController
@ModelAttribute("userDetails")
public UserDetails newUserDetails() {
return new UserDetails();
}
@ModelAttribute("months")
public int[] getMonthList() {
return new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
}
}
14. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Definition of a single model attribute
@Controller
public class ValidateUserFormController
@RequestMapping(method = RequestMethod.GET)
public String validateForm(HttpServletRequest request, HttpServletResponse ...) {
String firstName = request.getParameter(‚firstName‛);
String lastName = request.getParameter(‚lastName‛);
// ...
}
}
15. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Definition of a single model attribute
@Controller
public class ValidateUserFormController
@RequestMapping(method = RequestMethod.GET)
public String validateForm(@ModelAttribute("userDetails") UserDetails details) {
// ...
}
@ModelAttribute("userDetails")
public UserDetails getUserDetails(HttpServletRequest request) {
UserDetails user = new UserDetails();
user.setFirstName(request.getParameter("firstName"));
return user;
}
}
16. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Definition of a single model attribute
public class UserFormControllerTest {
@Test
public void testValidateForm() {
UserFormController formController = new UserFormController();
UserDetails userDetails = new UserDetails();
// ...
// Simple way to test a method.
String viewName = formController.validateForm(userDetails);
Assert.assertEquals("OK", viewName);
}
}
17. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Definition of a multiple model attribute
@ModelAttribute("months")
public int[] getMonthList() {
return new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
}
@ModelAttribute("months")
public int[] getYears() {
return new int[] { 1940, 1941, ... };
}
@ModelAttribute
public void populateAllAttributes(Model model, HttpServletRequest ...) {
model.addAttribute(‚years", new int[] { ... });
model.addAttribute(‚months", new int[] { ... });
18. Spring MVC – Advanced topics
Annotation driven controllers
@ModelAttribute
» Session attribute binding
@Controller
@SessionAttributes("userDetails");
public class ValidateUserFormController {
// UserDetails instance is extracted from the session.
@RequestMapping(method = RequestMethod.GET)
public String validateForm(@ModelAttribute("userDetails") UserDetails details) {
// ...
}
}
19. Spring MVC – Advanced topics
Annotation driven controllers
@CookieValue, @HeaderValue
» @CookieValue provide access to client-side cookies.
» @HeaderValue provide access to HTTP request header
values.
20. Spring MVC – Advanced topics
Annotation driven controllers
@DateTimeFormat
» Allow conversion of a string to date-class type.
long/java.lang.Long,
java.util.Date, java.sql.Date,
java.util.Calendar,
Joda time
» Applies to @RequstParam and @PathVariable
» Support various conventions.
21. Spring MVC – Advanced topics
Annotation driven controllers
@DateTimeFormat
@Controller
public class CheckDatesRangeController {
// http://host.com/checkDate?birthDate=1975/02/31
@RequestMapping
public String checkDateRange(
@RequestParam("birthdate")
@DateTimeFormat(pattren = "yyyy/mm/dd") Date birthDate) {
// ...
}
}
22. Spring MVC – Advanced topics
Annotation driven controllers
@RequestBody
» Provide access to HTTP request body.
@Controller
public class PersistCommentController {
@RequestMapping(method = RequestMethod.POST)
public String checkDateRange(@RequestBody String contents) {
// ...
}
}
» Also supported:
Byte array, Form, javax.xml.transform.Source
23. Spring MVC – Advanced topics
Annotation driven controllers
@ResponseBody
» Convert return value to HTTP response body.
@Controller
public class FetchCommentController {
@RequestMapping
@ResponseBody
public String fetchComment(@RequestMapping (‚commentId") int commentId) {
// ...
}
@RequestMapping
@ResponseBody
public byte[] fetchAsBinary(@RequestMapping (‚commentId") int commentId) {
// ...
}
}
25. Spring MVC – Advanced topics
Arguments and return types
@Controller
public class SomeController {
@RequestMapping
public String someMethod(...) { ... }
}
Return Arguments
value
26. Spring MVC – Advanced topics
Arguments and return types
Allowed arguments
» HttpServletRequest, HttpServletResponse, HttpSession
Servlet API
» WebRequest, NativeWebRequest
Spring framework API
» java.util.Locale
» java.io.InputStream, java.io.Reader
» java.io.OutputStream, java.io.Writer
27. Spring MVC – Advanced topics
Arguments and return types
Allowed arguments
» java.security.Principle
» HttpEntity
Spring framework API
» java.util.Map, Model, ModelMap
Allow access to the current model.
» Errors, BindingResult
28. Spring MVC – Advanced topics
Arguments and return types
Allowed return types
» ModelAndView, Model, java.util.Map, View
» String
Represents a view name, if not specified otherwise.
» void
» HttpEntity<?>, ResponseEntity<?>
» Any other type that has a conversion.
30. Spring MVC – Advanced topics
Validation
» Allow us to validate form in a discipline manner.
» Provide a convenient and consistent way to validate
input.
» Support JSR-303 (not covered by this presentation).
31. Spring MVC – Advanced topics
Validation
Declaring binding process
@Controller
public class ValidateFormController {
@RequestMapping
public String validateForm(UserDetails details, Errors errors) {
if (details.getFirstName() == null) {
errors.rejectValue("firstName", null, "Missing first name.");
}
}
}
32. Spring MVC – Advanced topics
Validation
Declaring binding process
@Controller
public class ValidateFormController {
@RequestMapping
public String validateForm(UserDetails details, Errors errors) {
ValidationUtils.rejectIfEmpty(errors,
"firstName",
null,
"Missing first name.");
}
}
33. Spring MVC – Advanced topics
Validation
Declaring binding process
<form:form action="form/validate.do" method="POST" modelAttribute="userDetails">
<!-- Prompt for user input -->
First name: <form:input path="firstName" />
<!-- Display errors related to ‘firstName’ field -->
<form:errors path="firstName"/>
</form:form>
34. Spring MVC – Advanced topics
Validation
JSR-303 based validation
» Spring framework support 3rd-party JSR-303
integration.
» Requires additional artifacts JSR-303 spec artifacts.
» Requires RI (reference implementation)
e.g: Hibernate Validation
35. Spring MVC – Advanced topics
Validation
JSR-303 based validation
@RequestMapping
public String validateForm(@Valid UserDetails details, Errors errors) { ... }
public class UserDetails {
@NotNull // JSR-303 annotation.
private String firstName;
@Size(min = 2, max = 64) // JSR-303 annotations.
private String lastName;
@Min(1) @Max(12) // JSR-303 annotations.
private int birthMonth;
}