background preloader

Spring

Facebook Twitter

Stack Overflow. Spring - java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener. Java - JPA map collection of Enums. Spring - java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener. Spring MVC file upload example. Simple Spring Web Services using JAXB for Marshalling. Spring 3 File Upload Example. I had the opportunity to figure out how to do file uploads using Spring 3 the other day and I couldn't find anything that pulled it all together.

Spring 3 File Upload Example

What follows is a complete example of how to do MVC based file uploads with Spring 3. I'm going to assume you know something about Spring and their MVC configuration in general. If you want a simple MVC example to start with check out their SVN MVC-Basic sample. There is a decent amount of boiler plate work so I've created a project zip file with all the code, a build file and configuration in it (you just need to add the libraries).

First lets start by gathering up all the libraries we are going to need (see the end of the post for the directory layout I used or just unzip the project). Next it is worth a quick look at the information provided in the Spring documentation about MVC multipart. Spring 3 MVC ContentNegotiatingViewResolver example. Spring 3, ContentNegotiatingViewResolver, is an interesting view resolver, which allow you to output a same resource (content or data) to different type of views like JSP, XML, RSS, JSON and etc.

Spring 3 MVC ContentNegotiatingViewResolver example

Put it simple, see following web requested URL, which will return in different views. , returned as RSS file. , returned as XML file. , returned as JSON file. returned to your default view resolver. Note This ContentNegotiatingViewResolver first determine “which view resolver should return by file extension”, if no view is match, then use the default view resolver. Read this Spring documentation to study how it works. In this tutorial, we show you how to use ContentNegotiatingViewResolver.

Exploding Java: Simple Synchronizer Token with Spring MVC. The Problem If you have used Struts 1.x, you'll probably be familiar with using the synchronizer token functionality provided through the saveToken() and isTokenValid() methods of the Action class.

Exploding Java: Simple Synchronizer Token with Spring MVC

These prevent duplicate form submission, either as a result of double-clicking a submit button, or trying to submit a form from the browser history after using the back button. Out of the box, Spring MVC doesn't have similar functionality, although it is being addressed with Spring Web Flow: How to prevent user from double clicking the submit in a form using spring MVCAbstractTokenTransactionSynchronizer So how could you use the synchronizer token pattern with Spring MVC if you aren't using Spring Web Flow? Spring Integration. Introduction Using the Spring Framework encourages developers to code using interfaces and use dependency injection (DI) to provide a Plain Old Java Object (POJO) with the dependencies it needs to perform its tasks.

Spring Integration

Spring Integration takes this concept one step further, where POJOs are wired together using a messaging paradigm and individual components may not be aware of other components in the application. Such an application is built by assembling fine-grained reusable components to form a higher level of functionality. WIth careful design, these flows can be modularized and also reused at an even higher level.

16. Domain Object Security (ACLs) Complex applications often will find the need to define access permissions not simply at a web request or method invocation level.

16. Domain Object Security (ACLs)

Instead, security decisions need to comprise both who (Authentication), where (MethodInvocation) and what (SomeDomainObject). In other words, authorization decisions also need to consider the actual domain object instance subject of a method invocation. Imagine you're designing an application for a pet clinic. There will be two main groups of users of your Spring-based application: staff of the pet clinic, as well as the pet clinic's customers. The staff will have access to all of the data, whilst your customers will only be able to see their own customer records.

20. Remoting and web services using Spring. The RestTemplate is the core class for client-side access to RESTful services.

20. Remoting and web services using Spring

It is conceptually similar to other template classes in Spring, such as JdbcTemplate and JmsTemplate and other template classes found in other Spring portfolio projects. RestTemplate's behavior is customized by providing callback methods and configuring the HttpMessageConverter used to marshal objects into the HTTP request body and to unmarshal any response back into an object. Appendix A. Spring Integration Samples. Currently Spring Integration comes with quite a few samples and you can only expect more.

Appendix A. Spring Integration Samples

To help you better navigate through them, each sample comes with its own readme.txt file which covers several details about the sample (e.g., what EIP patterns it addresses, what problem it is trying to solve, how to run sample etc.). However, certain samples require a more detailed and sometimes graphical explanation. In this section you'll find details on samples that we believe require special attention. In this section, we will review the Loan Broker sample application that is included in the Spring Integration samples. This sample is inspired by one of the samples featured in Gregor Hohpe and Bobby Woolf's book, Enterprise Integration Patterns.

The diagram below represents the entire process Now lets look at this process in more detail At the core of an EIP architecture are the very simple yet powerful concepts of Pipes and Filters, and of course: Messages. Messaging Gateway Message Router. SpringSource/spring-integration-samples. Spring MVC 3 and jQuery Integration Tutorial. In this tutorial we will build a simple Spring MVC 3 application with AJAX capabilities using jQuery.

Spring MVC 3 and jQuery Integration Tutorial

We will explore how to post data using jQuery.post() and process the result. We will be developing a non-AJAX application first then convert it to an AJAX-powered version later. What is jQuery? jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.Source: What is AJAX? Ajax is a group of interrelated web development methods used on the client-side to create interactive web applications. Our application is a simple arithmetic operation that adds two numbers and displays the sum. Here's a screenshot of the AJAX version: Notice nothing much is different, except that the non-AJAX version will display the result on another page, while the AJAX version will display on the same page. NonAjaxController Here are the JSP pages: Uniform - Sexy forms with jQuery. Sexy form elements with jQuery.

Uniform - Sexy forms with jQuery

Now with HTML5 attributes! » 5 Minute Guide to Spring Security. Update!

» 5 Minute Guide to Spring Security

May 31, 2010: I have published a new book, Spring Security 3, covering many aspects of Spring Security from top to bottom. The book is targeted both at novices and intermediate to advanced users. I’d encourage you to read my blog post of the announcement, and visit the book’s web site, to determine if you think it will help you. Although I’ve used Acegi Security in the past, I hadn’t tried it since it was renamed Spring Security and folded into the Spring Portfolio.

Blogs for Development: Integrating Spring Security 3 with Extjs. It has a lot of differences and developments in Spring Security 3 versus 2, for this I thought to add this article.. The following tutorial will talk about how integrating Spring security 3 with extjs login page. Tools: [#SPR-3179] CODE CONTRIBUTION: JPA support for JSF - OpenEntityManagerViewPhaseListener - Spring Projects Issue Tracker. I could not find the JSF equivalent of the org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter support class in Spring. Existing classes out there provided hibernate-specific PhaseListeners, but none worked using the JPA api. I have merged code posted by Rick Hightower at and code from org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter and created a OpenEntityManagerInViewPhaseListener. Also, in order to hook it from the servletContext, I have create the OpenEntityManagerInViewPhaseListenerDelegator (which reproduces the same pattern as the org.springframework.web.filter.DelegatingFilterProxy class)