Sitemap    
  Home Food Photographs IT Parenting Resources Learning  
JAVA
J2SE
JSP
Servlet
Spring
Adding logging to the application
Get Started 1
Get Started 2
Get Started 3
Get Started 4
Simple file upload using Spring 1
Simple file upload using Spring 2
Simple file upload using Spring 3
Simple file upload using Spring 4
Spring3 And Hibernate 1
Spring3 And Hibernate 2
Spring3 And Hibernate 3
Spring3 And Hibernate 4
Spring3 Getting Started 1
Spring3 Getting Started 2
Spring3 Getting Started 3
Spring3 Getting Started 4
Spring3 Simple file upload 1
Spring3 Simple file upload 2
Spring3 Simple file upload 3
Spring3 Simple file upload 4
Struts2
Webservice
Simple file upload using Spring 2
3: /WEB-INF/fileupload-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="prop-config"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:fileupload.DEV.properties</value>
        </list>
    </property>
</bean>

<!--
    contains message resource bundle to support dynamic message templates.
    alias is added for due to autowiring spring's internal beans.
-->
<bean id="messages"
    class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="message" />
</bean>
<alias name="messages" alias="messageSource" />

<bean id="view-resolver"
  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

<bean id="exception-resolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    <property name="exceptionMappings">
        <props>
            <prop key="java.lang.Exception">ErrorPage</prop>
        </props>
    </property>
</bean>

<!-- the application context definition for the springapp DispatcherServlet -->
<bean id="url-mapping"
  class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <map key-type="java.lang.String"
            value-type="java.lang.String">
            <entry key="/Upload" value-ref="uploadController" />
        </map>
    </property>
</bean>


<!-- .................................................................. -->
<!-- controller layer -->
<!-- .................................................................. -->

<!-- base config. for all controller beans, which should be subclass of SimpleFormController -->
<bean id="uploadController"
class="com.company.fileupload.UploadController">
    <property name="supportedMethods" value="GET,POST" />
    <property name="requireSession" value="false" />
    <property name="useCacheControlHeader" value="true" />
    <property name="useCacheControlNoStore" value="true" />
    <property name="useExpiresHeader" value="true" />
    <property name="commandClass"
        value="com.company.fileupload.UploadCommand" />
    <property name="formView" value="upload" />
    <property name="successView" value="uploadSuccess" />
    <property name="uploadFolderPath">
        <value>${docs.upload.folder}</value>
    </property>
</bean>

<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <!-- one of the properties available; the maximum file size in bytes -->
    <property name="maxUploadSize" value="52428800 " />
</bean>
</beans>

Note use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer and org.springframework.web.multipart.commons.CommonsMultipartResolver
/WEB-INF/classes/fileupload.DEV.properties
ADD TO DEL.ICIO.US ADD TO DIGG ADD TO FURL ADD TO REDDIT ADD TO STUMBLEUPON ADD TO TECHNORATI FAVORITES ADD TO SQUIDOO ADD TO YAHOO MYWEB ADD TO ASK ADD TO GOOGLE
Post your comments:
Your Name: 
Security check:
Your Comment: 1500 chars
Latest
How to loop arraylist JAVA6 Syntax
How to iterrate through ArrayList and display multiple rows using for loop JAVA6 syntax..
Java JSP  2010-Oct-12
How to loop arraylist
How to iterrate through ArrayList and display multiple rows using for loop, JSTL tags..
Java JSP  2010-Oct-12
Consumer using JAX WS Dispatch API and DOM parser 1
Access/Consume Webservice using Servlet, JAX-WS Dispatch API dynamic client and parsing SOAP response using DOM parser...
Java Webservice  2010-Sep-20
Simple Java first CXF Webservice 4
Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
Java Webservice  2010-Sep-19
Simple Java first CXF Webservice 3
Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
Java Webservice  2010-Sep-18
Simple Java first CXF Webservice 1
Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
Java Webservice  2010-Sep-18
Simple Java first CXF Webservice 2
Building Simple Java first CXF webservice using CXFServlet, Spring, jaxws:endpoint, @WebService, @SOAPBinding, @WebResult
Java Webservice  2010-Sep-18
Encoding special characters in userinput or on server
Encoding can be done either in Javascript or JAVA encodeURIComponent, escape, java.net.URLEncoder..
Java JSP  2010-Aug-09
Jstl fmt tag i18n formatdate formatcurrency
fmt:setBundle, native2ascii.exe, fmt:message, fmt:setLocale, fmt:formatDate, fmt:formatNumber type=currency..
Java JSP  2010-Aug-05
How to read and write a file
How to read and write a file java.io.BufferedReader,java.io.FileReader, InputStreamReader ...
Java J2SE  2010-Aug-04
jQuery validate form using ajax 2
How to validate/submit form using ajax and jQuery input#, ($.ajax)..
Javascript  2010-Jul-23
jQuery validate form using ajax 1
How to validate/submit form using ajax and jQuery ($.ajax)..
Javascript  2010-Jul-23
How to create datasource in RAD Websphere
Create JDBC provider, datasource and JAAS security setup, JDBC connection URLs
Servers Websphere  2010-Jul-08
Get Started 4
Struts2 framework structure, how various components fit together
Java Struts2  2010-Jul-07
How to populate a form when JSP is called first time
This is achieved throught setting bean in request, using frameworks like Struts2, Spring3..
Java JSP  2010-Jul-07
Spring3 And Hibernate 4
Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
Java Spring  2010-Jul-07