Book Image

Mastering Spring MVC 4

By : Geoffroy Warin
Book Image

Mastering Spring MVC 4

By: Geoffroy Warin

Overview of this book

<p>Spring MVC is the ideal tool to build modern web applications on the server side. With the arrival of Spring Boot, developers can really focus on the code and deliver great value, leveraging the rich Spring ecosystem with minimal configuration.</p> <p>Spring makes it simple to create RESTful applications, interact with social services, communicate with modern databases, secure your system, and make your code modular and easy to test. It is also easy to deploy the result on different cloud providers.</p> <p>Mastering Spring MVC will take you on a journey from developing your own web application to uploading it on the cloud.</p> <p>You begin by generating your own Spring project using Spring Tool suite and Spring Boot.</p> <p>As you develop an advanced-level interactive application that can handle file uploads as well as complex URLs, you will dive into the inner workings of Spring MVC and the principles of modern web architectures.</p> <p>You will then test, secure, and optimize your Spring web application and design RESTful services that will be consumed on the frontend.</p> <p>Finally, when everything is ready, you will release your application on a cloud provider and invite everyone to see.</p>
Table of Contents (17 chapters)
Mastering Spring MVC 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Material design with WebJars


Our application is already great but it seriously leaves something to be desired in terms of aesthetics. You may have heard of material design. It is Google's take on flat design.

We will use Materialize (http://materializecss.com), a great looking responsive CSS and JavaScript library, just like Bootstrap.

We talked a bit about WebJars in Chapter 1, Setting Up a Spring Web Application in No Time; we will now get to use them. Add jQuery and Materialize CSS to our dependencies:

compile 'org.webjars:materializecss:0.96.0'
compile 'org.webjars:jquery:2.1.4'

The way a WebJar is organized is completely standardized. You will find the JS and CSS files of any library in /webjars/{lib}/{version}/*.js.

For instance, to add jQuery to our page, the following to a web page:

<script src="/webjars/jquery/2.1.4/jquery.js"></script>

Let's modify our controller so that it gives us a list of all tweet objects instead of simple text:

package masterSpringMvc.controller;

import...