Announcement Announcement Module
Collapse
No announcement yet.
Mvc Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mvc

    I am 3 months old to Spring and i am having problem with fileupload using MVC. I have the following code:

    Code:
    //web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>SpringMVCUpDownload</display-name>
      
      	<!--  
      			This example was taken from the website
      			http://gardiary.wordpress.com/2010/04/06/file-upload-and-download-using-spring-mvc/  	
      	 -->    
      	 	<context-param>
            	<param-name>contextConfigLocation</param-name>
            	<param-value>/WEB-INF/applicationContext.xml</param-value>
        	</context-param>
        
         	<listener>
            	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        	</listener>   
        
        	<servlet>
            	<servlet-name>dispatcher</servlet-name>
            	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            	<load-on-startup>2</load-on-startup>
        	</servlet>
        
        	<servlet-mapping>
            	<servlet-name>dispatcher</servlet-name>
            	<url-pattern>*.htm</url-pattern>
        	</servlet-mapping>  
      
      		<welcome-file-list>   
        		<welcome-file>index.jsp</welcome-file>   
      		</welcome-file-list>
    </web-app>
    I have this in dispatcher-servlet.xml
    Code:
    <?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:p="http://www.springframework.org/schema/p"
    		xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    	
    	<!-- mapping -->
    	    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	        <property name="mappings">
    	            <props>
    	                <prop key="files.htm">filesForm</prop>
    	                <prop key="upload.htm">filesController</prop>
    	                <prop key="download.htm">filesController</prop>
    	                <prop key="delete.htm">filesController</prop>
    	            </props>
    	        </property>
    	    </bean>	
    	    
    	     <!-- The view resolver -->
    	    <bean id="viewResolver"
    	          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    	          p:prefix="/WEB-INF/jsp/"
    	          p:suffix=".jsp" >
    		</bean>
    		
    		<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    	        <property name="maxUploadSize" value="5242880" />
    	    </bean>
    	    
    	    <!-- controller -->
    	    <bean id="filesForm" class="com.SpringMVCUpDownload.form.FilesForm">
    	        <property name="filesService" ref="filesService"/>
    	    </bean>
    		
    		<bean id="filesController" class="com.SpringMVCUpDownload.controller.FilesController">
    	        <property name="filesService" ref="filesService"/>
    	        	<property name="methodNameResolver">
    	            	<bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
    	                	<property name="mappings">
    	                    	<props>
    	                        	<prop key="/upload.htm">upload</prop>
    	                        	<prop key="/download.htm">download</prop>
    	                        	<prop key="/delete.htm">delete</prop>
    	                    	</props>
    	                	</property>
    	           	 </bean>
    	        </property>
    	    </bean>		
    </beans>
    I have all the jar files and when i deploy i get the index.jsp and when i click on the go to upload page i get

    http://localhost:8089/SpringMVCUpDow...uploadForm.htm

    The requested resource is not available. I am using Eclipse Indigo and Tomcat 6.

    Please help I have to implement in my application.

  • #2
    What is the problem you facing? plz send error log and relevant JSP you using for Uploading.

    Comment

    Working...
    X