Results 1 to 2 of 2

Thread: Spring MVC configuration problem

  1. #1
    Join Date
    Mar 2012
    Posts
    1

    Exclamation Spring MVC configuration problem

    Hi I am trying to build a spring mvc web project.But just get 404 always.
    my web.xml:
    Code:
     <servlet>
           <servlet-name>action</servlet-name>
           <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
            </servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping> 
      		<servlet-name>action</servlet-name> 
     		<url-pattern>*.jsp</url-pattern>
    	</servlet-mapping>
    	 <welcome-file-list>
           <welcome-file>index.jsp</welcome-file>
       </welcome-file-list>
       <listener>
    	<listener-class>
    		org.springframework.web.context.ContextLoaderListener
    	</listener-class>
    	</listener>
    my action-servlet.xml:
    Code:
    <context:component-scan base-package="mypakage.Controller"/>  
          
        <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        	<property name="cacheSeconds" value="0" />
    	</bean>
    	
    	<bean id="jspViewResolver" 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>
    jsp files are under /WEB-INF/jsp/
    In my controller
    Code:
    @RequestMapping(value="/index",method=RequestMethod.GET)
    Could anyone please point out what's wrong here? Or give me some suggestions!
    Thank you very much and have a good night!

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Don't map *.jsp to the dispatcher servlet make it something else. Also you have mapped *.jsp to the dispatcher servlet and expect /index to be matched that is obviously never going to happen.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •