badgerduke
May 8th, 2011, 02:59 PM
Spring 3.0.5
Tomcat 7.0.12
Hello:
I am new to Spring MVC and having trouble. When I enter the URL "http://localhost:8080/FantasyPro/"
I get a 404 and the following message appears in my console:
WARNING: No mapping found for HTTP request with URI [/FantasyPro/] in DispatcherServlet with name 'fantasypro'
I am trying to get to /index.html.
Here is my controller:
1. package com.fantasypro.mvc.controller;
2.
3. import org.springframework.stereotype.Controller;
4. import org.springframework.web.bind.annotation.RequestMap ping;
5.
6. @Controller
7. public class HomeController {
8.
9. @RequestMapping("/")
10. public String showHomePage() {
11. System.out.println("DDDDDDDDDDDDD");
12. return "index";
13. }
14.
15.
16. }
Here is my web.xml:
1. <?xml version="1.0" encoding="UTF-8"?>
2. <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_3_0.xsd" id="WebApp_ID" version="3.0">
3. <display-name>FantasyPro</display-name>
4. <servlet>
5. <servlet-name>fantasypro</servlet-name>
6. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
7. <load-on-startup>1</load-on-startup>
8. </servlet>
9.
10. <servlet-mapping>
11. <servlet-name>fantasypro</servlet-name>
12. <url-pattern>/</url-pattern>
13. </servlet-mapping>
14.
15. </web-app>
Here is my context file (fantasypro-servlet.xml):
1. <?xml version="1.0" encoding="UTF-8"?>
2. <beans xmlns="http://www.springframework.org/schema/beans"
3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4. xmlns:mvc="http://www.springframework.org/schema/mvc"
5. xmlns:context="http://www.springframework.org/schema/context"
6. xsi:schemaLocation="http://www.springframework.org/schema/mvc
7. http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
8. http://www.springframework.org/schema/context
9. http://www.springframework.org/schema/context/spring-context-3.0.xsd
10. http://www.springframework.org/schema/beans
11. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
12.
13. <mvc:annotation-driven/>
14. <context:component-scan base-package="com.fantasypro.mvc.controller" />
15. <mvc:resources mapping="/js/**" location="/js/"/>
16.
17. <bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
18. <property name="prefix" value="/"/>
19. <property name="suffix" value=".html"/>
20. </bean>
21. </beans>
This is driving me nuts. Can anybody see a problem?
Thanks,
Eric
Tomcat 7.0.12
Hello:
I am new to Spring MVC and having trouble. When I enter the URL "http://localhost:8080/FantasyPro/"
I get a 404 and the following message appears in my console:
WARNING: No mapping found for HTTP request with URI [/FantasyPro/] in DispatcherServlet with name 'fantasypro'
I am trying to get to /index.html.
Here is my controller:
1. package com.fantasypro.mvc.controller;
2.
3. import org.springframework.stereotype.Controller;
4. import org.springframework.web.bind.annotation.RequestMap ping;
5.
6. @Controller
7. public class HomeController {
8.
9. @RequestMapping("/")
10. public String showHomePage() {
11. System.out.println("DDDDDDDDDDDDD");
12. return "index";
13. }
14.
15.
16. }
Here is my web.xml:
1. <?xml version="1.0" encoding="UTF-8"?>
2. <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_3_0.xsd" id="WebApp_ID" version="3.0">
3. <display-name>FantasyPro</display-name>
4. <servlet>
5. <servlet-name>fantasypro</servlet-name>
6. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
7. <load-on-startup>1</load-on-startup>
8. </servlet>
9.
10. <servlet-mapping>
11. <servlet-name>fantasypro</servlet-name>
12. <url-pattern>/</url-pattern>
13. </servlet-mapping>
14.
15. </web-app>
Here is my context file (fantasypro-servlet.xml):
1. <?xml version="1.0" encoding="UTF-8"?>
2. <beans xmlns="http://www.springframework.org/schema/beans"
3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4. xmlns:mvc="http://www.springframework.org/schema/mvc"
5. xmlns:context="http://www.springframework.org/schema/context"
6. xsi:schemaLocation="http://www.springframework.org/schema/mvc
7. http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
8. http://www.springframework.org/schema/context
9. http://www.springframework.org/schema/context/spring-context-3.0.xsd
10. http://www.springframework.org/schema/beans
11. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
12.
13. <mvc:annotation-driven/>
14. <context:component-scan base-package="com.fantasypro.mvc.controller" />
15. <mvc:resources mapping="/js/**" location="/js/"/>
16.
17. <bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
18. <property name="prefix" value="/"/>
19. <property name="suffix" value=".html"/>
20. </bean>
21. </beans>
This is driving me nuts. Can anybody see a problem?
Thanks,
Eric