Wednesday, June 20, 2012

File Upload with Spring and jQuery (Part 2)

Review

In the previous section, we have laid down the functional specs of the application. In this section, we will start writing the Java classes and discuss the project's structure.


Project Structure

Our application is a Maven project which means our project follows the Maven structure.

Here's a preview of our project's structure:





Domain Layer

The domain layer contains a Message class that is used as a container to hold file details.

Message.java


The domain layer also contains an UploadedFile class which is used for sending file information after it has been processed by the controller.

UploadedFile.java


Controller Layer

The controller layer contains a simple controller that serves a form for uploading files. There are two important endpoints here:
  • /message - processes the file descriptions
  • /file - receives the files themselves

To simplify this tutorial, we're not persisting the messages and files in a database or to the disk.

UploadController.java


Others

StatusResponse is used to determine the status of a request, and includes an error message if any.

StatusResponse.java


Next

We've completed writing our Java classes. In the next section, we will start writing the configuration files. Click here to proceed.
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google I'm reading: File Upload with Spring and jQuery (Part 2) ~ Twitter FaceBook

Subscribe by reader Subscribe by email Share

9 comments:

  1. Please correct the link to the Part 1.

    ReplyDelete
    Replies
    1. Thanks for pointing that out. It's now corrected. Cheers

      Delete
  2. i cannot see java files, could you please correct it.

    ReplyDelete
    Replies
    1. It's on Part I. See https://github.com/krams915/spring-fileupload-tutorial/tree/master/spring-fileupload-tutorial

      Delete
  3. This is good for file having small in size may be less than 10 MB. Please tell us for processing bigger files like 200 MB and 300 MB files.

    ReplyDelete
  4. I have read your blog its very attractive and impressive. I like it your blog.

    Spring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training

    spring training in chennai spring hibernate training in chennai

    ReplyDelete