Spring MVC View - spring

What are you guys using for your view in Spring MVC.
I know Spring MVC has a wide support for views but I'm having trouble finding what works well, what view to use when, etc.
Any insight would be great!

JSP, of course.
Sometimes PDF; Excel when necessary.
BlazeDS makes Flex integration with Spring possible. That's a great way to go if you use Flex.
"...I'm having trouble finding what works well..." - they all work well from Spring's point of view.
What to use when? Use the technology that you know best. Spring can deal with all of them just fine.
UPDATE: Since this was written three years ago, I'll amend it by saying that I would recommend just using Velocity templates to marry with dynamic data. Templates should use HTML, CSS, JavaScript, and jQuery. I think that provides the best flexibility you can have. You "future proof" your design if you can generate responsive HTML 5 pages.

We are using the following templating languages
Apache Velocity: Most of our old projects are using apache velocity to render the view. This is a very easy to learn and use language. But here xml operations are very limited.
Freemarker: Now we are migrating our project to Freemarker. This is a very good templating language. Advantage over velocity is that it has a very good support for xml data processing

You can use jsp with struts tiles to give good and uniform experience. You can refer to "Spring in Action" Book to find out how to do it. I have used this combination for developing my website www.propertymela.net. Have a look.

I am using Thymeleaf, because it has static prototyping which is very useful when there are two teams doing web design and server side development. I believe JSP is a fairly old technology, and I've had some problems with using HTML5 with it, which is why I opted to use a different view technology.
Also, Velocity is a competitor of Thymeleaf but I haven't really touched on Velocity aside from creating email templates.

JSTL is my option. JSTL has all the functional component which we can achieve through the use of scriplets in JSP. The avoidance of the scriptlet code in JSP is key to move into JSTL
In scriplet code if anything wrong whole page breaks. But it is not in the case of JSTL

Related

Spring boot and vuejs web app implementation approach

I wrote a spring boot application and I want to use Vuejs for the front-end. I found online two ways to do this:
1 - store my html+vuejs in the resources/folder and use Thymeleaf and a controller to serve them.
2 - expose my spring rest-controllers and have my Vuejs application running separately and accessing the rest-api.
My question is: what is the difference between both approaches? and what approach is the most common?
Both approaches are equivalent it's just a question of choice.
With thymeleaf you work with HTML/CSS/JS in and old fashioned way : you write your HTML, your CSS (or use your prefered css framework) and probably use jQuery as you know how to use it.
With VueJS things are a little complicated at first. You should learn a standart like ECMAScript (which will compile in to JavaScript with the help of Babel), the integration with your favorite css framework will be a litlle more complicated and the use of plugins is very different than you would do it with jQuery.
So it depends, if you want to grow as developer, learn some fun things and be "on top" you should take a look on VueJS but if you just need to "send something fast to production" you should make it with thymeleaf.
But let me underline that you can make everything you want with both approaches.

Spring MVC view technology: what to choose?

I want to create web-site with Spring back-end, but I can't choose what view technology to use: JSP, Velocity, or I should try to integrate JSF with my app. Which of this technologies is the most popular?
Looks like that JSP is a quite deprecated technology, but I hasn't found a proof of this thesis yet. Should I learn JSP, or try some another framework?
I´d use JSP+JSTL+Tiles, but mainly because everybody knows them. I could consider to use Freemarker or Velocity (Specially the first). However, I think Spring MVC and JSF are technologies that overlap, and using them together could be useless and dangerous.
I recommend you to take a look at this: http://docs.spring.io/autorepo/docs/spring/3.2.x/spring-framework-reference/html/view.html
And also at this: http://ihatejsf.com/

Do you need to use a framework to Ajaxify your java web app?

I am currently studying Java EE with Hibernate for a project. In The Web App I am creating I am planning to Ajaxify page contents, and Site wide audio player(Which I think would be implemented using AJAX).
I am using a JSP based MVC, no frameworks, Just Java EE and Hibernate. And I've heard that I need to use a Framework like JSF to be able to AJaxify may web-app. How true is this? Do I really need to learn JSF or other frameworks to be able to Ajaxify my web app? As much as possible I do not want to learn a new framework for now since it is a big learning curve. but if there's no other way to Ajaxify my web app, I'll study a framework.
You don't have to adopt any framework to use partial page updates and similar, you can construct and send requests "manually" with JavaScript, but this is much more tedious then using a framework like JSF, maybe coupled with a component library like primefaces.
EDIT: you can find an abundance of examples of ajax capabilities in the primefaces showcase. Primefaces uses JQuery internally.
EDIT2: I have found some resources on how to dispatch ajax requests with JQuery from a JSP page (I assumed that using JSP was almost equal to not using a framework ;)): here and here. I hope this is what you were looking for.
To add on #Kostja's answer -
I totally agree with him, with Ajax you just need to have a servlet to handle the HTTP requests, and proper JavaScript code.
Besides JSF,I would also consider to look at Apache Wicket - you can read here how Wicket handles Ajax.
The reason I'm suggesting Wicket is that it's more comfortable to some developers to work with somewhat more "component oriented" (swing-like) framework.

View technologies for a spring mvc web application

I'm developping a web application with Spring MVC, and I'm totally new in web design I want to write my Views, but i don't really know how to design all of that, I need about two views, One form for an advanced search for items, and the other for viewing results.
is there any framework or facilities that i can begin with ?
I've skimed view Technologies part in the spring documentation, I found:
JSP/JSTL
Tiles
Velocity & Freemaker
XSLT
Is that all i can use ? which one you recommand.
The mostly used view implementation (which also has best tool support) is JSP/JSTL.
From the Velocity/Freemarker family (sort of) you can look at ThymeLeaf - it's clean and really easy to learn. It also gives you ability to use natural templating - HTML files which, without changes, work in web application (as SpringMVC views) and when opened directly in browser.

Choosing Presentation layer for spring application?

i was using JSP and YUI with spring applications
and i want to use a new presentation layer like IceFaces or GWT or any other good one
but i am confused what to choose
i need to make a good looking view, and the technology must have a good support/samples, and easy to use, commonly used with spring, please advise, thanks.
I don't have enough experience in IceFaces, but GWT is really easy, rapid and full ajaxian. Also the SEO issues can be handled in GWT.
Although a bit old, check out:-
http://woork.blogspot.com/2009/01/10-beautiful-web-ui-libraries.html

Resources