Add Navigation Bar to Java Spring [Maven]

Add Navigation Bar to Java Spring [Maven]

Add navigation bar to your Spring Java project [Maven], start by adding something similar to the below example snipit

Just place below code inside the  tag.

<pre><code><nav role="navigation" class="navbar navbar-default">
<div class="">
<a href="http://www.dotsway.com" class="navbar-brand">dotsway blog -- your daily information gate</a>
</div>
<div class="navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/login">HomePage</a></li>
<li><a href="/link-page">Link</a></li>

</ul>
</div>
</nav></code></pre>

That's it ! now you have a navigation menu, but then you need to place the above code in all pages, instead you can use JSP fragments which will help you not to repeat the code but have a header JSP , footer...etc, to read about JSP Fragments click here.

Failed to convert property value of type java.lang.String to required type java.util.Date

Today while adding to Java file a text box of date, i got below error while updating it:

Failed to convert property value of type java.lang.String to required type java.util.Date

Problem:
The problem here that Spring cannot put the data into object and cannot map it's format, the solution is to bind it to format you want to use.

Solution:
A data binder is needed, what is that ? how it's implemented ? let me answer those questions in the coming few lines.

If you have a date in a format like "mm-dd-yyyy" then it needs to be parsed, either you will do it manually after the @RequestParam Date or you will use like below or even using the WebDataBinder like Ex#2:
Continue reading

How to format date in Java Spring JSP

How to format the date in the JSP ?
You need to add in the jsp a tag library which used for formatting which called JSTL format, below is the JSP "View" part:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:formatDate pattern="dd-MM-yyyy" value="${project.projectStartdate}" />