Tag Archives: Spring MVC

Configuring Apereo CAS

This tutorial is designed to help a new CAS user to setup Apereo CAS server and client to their applications. The code of this tutorial is open sourced on GitHub. What's CAS? Enterprise Single Sign-On - CAS provides a friendly open source community that actively supports and contributes to the project. While the project is rooted in higher-ed open source, it has grown to an international audience spanning Fortune 500 companies and small special-purpose installations. CAS provides enterprise single sign-on service for the Web: An open and well-documented protocol An open-source Java server component Pluggable authentication support (LDAP, database, X.509, 2-factor) Support for multiple protocols (CAS, SAML, OAuth, OpenID) A library of clients for Java, .Net, PHP, Perl, Apache, uPortal, and others Integrates with…

Continue Reading

Use Server-Sent Event in Spring 4.2

Today, the Spring Framework released to 4.2 RC2. In Spring 4.2, better application events and Server-Sent Event(SSE) are supported. In this article, I'll introduce you the two new features. What's Server Sent Event Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is standardized as part of HTML5 by the W3C. Server-sent events is a standard describing how servers can initiate data transmission towards clients once an initial client connection has been established. They are commonly used to send message updates or continuous data streams to a browser client and designed to enhance native, cross-browser streaming through a JavaScript API called EventSource, through which a client…

Continue Reading

Use WebSockets with Spring, SockJS and Stomp

This guide walks you through the process of creating a "hello world" application that sends messages back and forth, between a browser and the server. WebSocket is a very thin, lightweight layer above TCP. It makes it very suitable to use "subprotocols" to embed messages. In this guide we’ll dive in and use STOMP messaging with Spring to create an interactive web application. Maven Dependencies First we need to add the Spring messaging modules in the POM file: Spring MVC Configuration Next, we need to add the message broker config to the Spring MVC config XML file. The main thing here is the set up of the message broker for handling the message exchange between the server and its clients. This…

Continue Reading

Spring MVC MyBatis Integration Tutorial

Last few months, I'm working at a project with Spring MVC and Hibernate. Now, I want to try MyBatis. In this article, I'll tell you how to useMyBatis with Spring MVC. According to WikiPedia, database transaction should provide an “all-or-nothing” proposition, stating that each work-unit performed in a database must either complete in its entirety or have no effect whatsoever. Further, the system must isolate each transaction from other transactions, results must conform to existing constraints in the database, and transactions that complete successfully must get written to durable storage. So on this example, im trying to create a simple MyBatis database transaction, managed by Spring Framework. Okay, so this is my pom file, as you can see, im using…

Continue Reading

Use CDN Service in Spring MVC

A few days ago, I created TestZilla on Aliyun Elastic Compute Service. However, with the increment of PV, I decided to use CDN to caches static files(images, css and javascripts). But there's no one told me how to use CDN with Spring MVC, so I asked a question on StackOverflow. Setup Spring Configuration First of all, you need to use PropertyPlaceholderConfigurer in Spring Configuration(such as dispatcher-servlet.xml) Of course, you need to add XML Namespaces: Create Properties File As I was declared in the Spring Configuration, there's a testzilla.properties in classpath. You need to create the file and add following lines in it: Of course, you can add extra properties if needed: Use CDN Property in JSP Now, we can get the…

Continue Reading

Sending Email with Spring MVC Using Template

This tutorial provides a sample spring MVC application that allows user sending an e-mail message. In this tutorial, you are supposed to familiar with Java EE development as well as developing Spring MVC-based applications. Spring Framework’s Support for E-mail Based on JavaMail, Spring framework provides high-level abstraction API which greatly simplifies e-mail sending process. Let’s take a brief look at this API in the following class diagram: To send e-mail messages, we can use an implementation of interface MailSender – the JavaMailSenderImpl class which is built upon on JavaMail. It’s convenient to configure this implementation as a bean in Spring’s context: Dependencies(pom.xml) The Mail Template File Name: verifyEmail.vm File Location: classpath: /mails/verifyEmail.vm (You can change this in configuration file) The…

Continue Reading
Contact Us
  • Room 311, Zonghe Building, Harbin Institute of Technology
  • cshzxie [at] gmail.com